Skip to content

Responsive & Container Queries

Adapt desktop and embedded Iced UIs to both window width and enclosing container width using standard Tailwind CSS v4 viewport prefixes and layout-time @container queries.

ISS preview
Responsive Iced card switching from stacked column at 360px to horizontal row at 840px
Same flex-col md:flex-row style resolved at 360px vs 840px
Prefix Condition Typed Equivalent
sm: / md: / lg: / xl: / 2xl: width >= 640 / 768 / 1024 / 1280 / 1536 px .sm(...) .. .xxl(...)
max-sm: .. max-2xl: width < 640 .. 1536 px .max_sm(...) .. .max_2xl(...)
md:max-xl: 768 px <= width < 1280 px `.md(
min-[520px]: / max-[900px]: Arbitrary pixel or rem threshold .min_w_bp(520.0, ...) / .max_w_bp(900.0, ...)

Mark any parent with @container (or a named container like @container/panel). During layout, ISS measures that container’s actual width so descendants respond to their allotted space regardless of window size.

Container Variant Threshold Named Form
@3xs: / @2xs: / @xs: 256 / 288 / 320 px @xs/card:
@sm: / @md: / @lg: / @xl: 384 / 448 / 512 / 576 px @sm/card:
@2xl: .. @7xl: 672 .. 1280 px @2xl/main:
@max-sm:, @min-[300px]:, @max-[500px]: Max-width and arbitrary bounds @max-[420px]/card:
use iced::widget::{container, text};
use iss::{col_tw, flex_tw, tw, IssViewport, TwExt};
let vp = IssViewport::with_theme(window_width, true);
let panel = col_tw(
[flex_tw(
[
text("Workspace").tw(tw!("text-sm @sm/panel:text-lg font-semibold text-white")),
container(text("Online").tw(tw!("text-xs text-emerald-300")))
.tw(tw!("px-2 py-0.5 rounded-md bg-emerald-500/15")),
],
tw!("w-full flex-col @sm/panel:flex-row items-start @sm/panel:items-center justify-between gap-2"),
)],
vp.tw(tw!("@container/panel w-full p-3 md:max-xl:p-5 bg-zinc-900 rounded-xl")),
);