Utilities
Container queries
Layout that follows the width of a box instead of the screen — the same widget can sit in a wide main area and a narrow sidebar and look right in both.
AK
Ana Kim
Wide box: a row
AK
Ana Kim
Narrow box: stacked
<div class="@container">
<div class="flex flex-col @md:flex-row @md:items-center gap-3">…</div>
</div>
The same markup twice: in the wide box it's a row, in the narrow one it stacks — because @md: asks "is my @container at least 28rem wide?", not the screen.
Try it: drag the corner
The cards switch from one column to two to three as the box gets wider — no screen breakpoints involved.
Revenue
Orders
Customers
Refunds
Visits
Conversion
<div class="@container">
<div class="grid grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3 gap-2">…</div>
</div>
| Prefix | When the container is at least |
|---|---|
@xs: | 20rem (320px) |
@sm: | 24rem (384px) |
@md: | 28rem (448px) |
@lg: | 32rem (512px) |
@xl: | 36rem (576px) |
@2xl: | 42rem (672px) |
Works with the layout essentials: block · flex · grid · hidden · flex-row · flex-col · flex-wrap · grid-cols-1…6 · items-* · justify-* · gap-2…8 · text-start / center / end · w-auto · w-full · w-1/2 · w-1/3. Mark the box with @container.