API
Layout
Position, overflow, containers, and stacking.
Where an element sits and how it clips. --display has a page of its own: display covers the flex directions, grid-pile, grid-gallery, and the subgrids, with an example of each. --isolation takes isolate or auto and is set once, at the base.
--container-type: inline-size makes an element a query container, so the breakpoint tiers inside it follow its width. --container-name names it, and --container is the CSS name / type shorthand, or none. --container-type and --container take breakpoints; the name is set once, at the base. Watch the shorthand: --container: inline-size sets a name, not a type. On a sticky element use --container-type with --container-name, because the shorthand drops the scroll-state type; the audit warns about it.
--anchor-name and --position-anchor take states and breakpoints, so the anchor can move with interaction: put --anchor-name--hover: --block on every block of an editor, and a toolbar with --position: absolute; --position-anchor: --block follows the hovered one. --position-area places it: --position-area: block-start span-inline-end puts the toolbar above the block, aligned to its start. For finer placement write anchor() in plain CSS. The inset utilities take numbers, lengths, and (on the four sides) auto, nothing else, so --top: anchor(bottom) computes to 0.
--top, --right, --bottom, and --left take auto at any breakpoint, which lets a side you set at one width go back to auto at another. A bar that sticks to the bottom of a phone screen and to the top of a desktop one is --position: sticky; --bottom: 0; --bottom--lg: auto; --top: auto; --top--lg: 0. --inset, --inset-x, and --inset-y take lengths only.
Reference
| Utility | Writes | Value | Tiers | Notes |
|---|---|---|---|---|
--aspect | aspect-ratio | any CSS value | breakpoints | works tier-only; --before-aspect / --after-aspect |
--display | display | keyword, plus flex shorthands that set the direction (flex-row, flex-row-reverse, flex-col, flex-col-reverse, inline-flex-row, inline-flex-row-reverse, inline-flex-col, inline-flex-col-reverse), grid-pile, which stacks the children in one cell, grid-gallery, which picks its column count from its child count, and subgrid, subgrid-col, subgrid-row, which take the parent grid's tracks | breakpoints | --before-display / --after-display |
--object-fit | object-fit | keyword | — | |
--object-position | object-position | any CSS value | — | |
--overflow | overflow | keyword | — | |
--overflow-x | overflow-x | keyword | — | |
--overflow-y | overflow-y | keyword | — | |
--position | position | keyword | breakpoints | works tier-only; --before-position / --after-position |
--anchor-name | anchor-name | dashed ident (--toolbar), a list of them, or none | breakpoints, states | works tier-only |
--position-anchor | position-anchor | dashed ident naming an anchor, auto, none, or normal | breakpoints, states | works tier-only |
--position-area | position-area | one or two area keywords (block-start span-inline-end), or none | breakpoints, states | works tier-only |
--inset | inset | scale number or length | breakpoints | --before-inset / --after-inset |
--inset-x | inset-inline | scale number or length | breakpoints | --before-inset-x / --after-inset-x |
--inset-y | inset-block | scale number or length | breakpoints | --before-inset-y / --after-inset-y |
--top | inset-block-start | scale number or length | breakpoints | Keywords: auto; --before-top / --after-top |
--right | inset-inline-end | scale number or length | breakpoints | Keywords: auto; --before-right / --after-right |
--bottom | inset-block-end | scale number or length | breakpoints | Keywords: auto; --before-bottom / --after-bottom |
--left | inset-inline-start | scale number or length | breakpoints | Keywords: auto; --before-left / --after-left |
--visibility | visibility | keyword | — | --before-visibility / --after-visibility |
--z | z-index | any CSS value | states | works tier-only; --before-z / --after-z |
--isolation | isolation | keyword | — | |
--container | container | any CSS value | breakpoints | |
--container-name | container-name | any CSS value | — | |
--container-type | container-type | any CSS value | breakpoints |
Examples
<div
style="
--position: relative;
--p: 6;
--w: 100%;
--h: 40;
--max-w: 96;
--bg: var(--color-muted);
--radius: 4.5;
"
>
<span
data-ui="badge"
data-badge-variant="primary"
style="
--position: absolute;
--top: 4;
--left: 4;
"
>--top: 4; --left: 4</span
>
<span
data-ui="badge"
data-badge-variant="muted"
style="
--position: absolute;
--top: 4;
--right: 4;
"
>--top: 4; --right: 4</span
>
<span
data-ui="badge"
data-badge-variant="muted"
style="
--position: absolute;
--bottom: 4;
--left: 4;
"
>--bottom: 4; --left: 4</span
>
<span
data-ui="badge"
data-badge-variant="primary"
style="
--position: absolute;
--bottom: 4;
--right: 4;
"
>--bottom: 4; --right: 4</span
>
<div
data-ui="text-xs"
style="
--display: flex;
--position: absolute;
--items: center;
--justify: center;
--inset: 6;
--font-weight: strong;
--text: var(--color-muted-foreground);
--border-color: var(--color-border);
--border-width: 1px;
--border-style: dashed;
--radius: 2.5;
"
>
--position: absolute; --inset: 6
</div>
</div>Scrollable region one
Scrollable region two
Scrollable region three
Scrollable region four
Scrollable region five
Scrollable region six
<div
style="
--display: grid;
--grid-cols: 2;
--gap: 6;
--w: 100%;
--max-w: 96;
"
>
<div
style="
--display: flex-col;
--gap: 2;
"
>
<div
style="
--display: flex-col;
--p: 4;
--gap: 2;
--h: 24;
--bg: var(--color-muted);
--radius: 2.5;
--overflow-x: clip;
--overflow-y: auto;
"
>
<p data-ui="text-sm">Scrollable region one</p>
<p data-ui="text-sm">Scrollable region two</p>
<p data-ui="text-sm">Scrollable region three</p>
<p data-ui="text-sm">Scrollable region four</p>
<p data-ui="text-sm">Scrollable region five</p>
<p data-ui="text-sm">Scrollable region six</p>
</div>
<span
data-ui="text-xs"
style="
--font-weight: strong;
--text-align: center;
--text: var(--color-muted-foreground);
"
>--overflow-y: auto</span
>
</div>
<div
style="
--display: flex-col;
--gap: 2;
"
>
<div
style="
--display: flex-col;
--p: 4;
--gap: 2;
--h: 24;
--bg: var(--color-muted);
--radius: 2.5;
--overflow: hidden;
"
>
<p data-ui="text-sm">Scrollable region one</p>
<p data-ui="text-sm">Scrollable region two</p>
<p data-ui="text-sm">Scrollable region three</p>
<p data-ui="text-sm">Scrollable region four</p>
<p data-ui="text-sm">Scrollable region five</p>
<p data-ui="text-sm">Scrollable region six</p>
</div>
<span
data-ui="text-xs"
style="
--font-weight: strong;
--text-align: center;
--text: var(--color-muted-foreground);
"
>--overflow: hidden</span
>
</div>
</div><div
style="
--display: grid;
--items: start;
--grid-cols: 3;
--gap: 6;
--w: 100%;
--max-w: 96;
"
>
<div
data-ui="text-xs"
style="
--display: flex;
--items: center;
--justify: center;
--p: 2;
--aspect: 1;
--font-weight: strong;
--text-align: center;
--text: var(--color-primary-foreground);
--bg: var(--color-primary);
--radius: 2.5;
"
>
--aspect: 1 · 1:1
</div>
<div
data-ui="text-xs"
style="
--display: flex;
--items: center;
--justify: center;
--p: 2;
--aspect: 16 / 9;
--font-weight: strong;
--text-align: center;
--text: var(--color-secondary-foreground);
--bg: var(--color-secondary);
--radius: 2.5;
"
>
--aspect: 16 / 9 · 16:9
</div>
<div
data-ui="text-xs"
style="
--display: flex;
--items: center;
--justify: center;
--p: 2;
--aspect: 2 / 3;
--font-weight: strong;
--text-align: center;
--text: var(--color-tertiary-foreground);
--bg: var(--color-tertiary);
--radius: 2.5;
"
>
--aspect: 2 / 3 · 2:3
</div>
</div><div
style="
--display: grid;
--grid-cols: 3;
--gap: 6;
--w: 100%;
--max-w: 96;
"
>
<figure
style="
--display: flex-col;
--gap: 2;
"
>
<img
src="https://images.unsplash.com/photo-1500382017468-9049fed747ef?auto=format&fit=crop&w=320&h=200&q=60"
width="320"
height="200"
loading="lazy"
alt="Savanna grass at dawn"
style="
--w: 100%;
--aspect: 1;
--bg: var(--color-muted);
--radius: 2.5;
--object-fit: cover;
"
/>
<figcaption
data-ui="text-xs"
style="
--font-weight: strong;
--text-align: center;
--text: var(--color-muted-foreground);
"
>
--object-fit: cover
</figcaption>
</figure>
<figure
style="
--display: flex-col;
--gap: 2;
"
>
<img
src="https://images.unsplash.com/photo-1500382017468-9049fed747ef?auto=format&fit=crop&w=320&h=200&q=60"
width="320"
height="200"
loading="lazy"
alt="Savanna grass at dawn"
style="
--w: 100%;
--aspect: 1;
--bg: var(--color-muted);
--radius: 2.5;
--object-fit: contain;
"
/>
<figcaption
data-ui="text-xs"
style="
--font-weight: strong;
--text-align: center;
--text: var(--color-muted-foreground);
"
>
--object-fit: contain
</figcaption>
</figure>
<figure
style="
--display: flex-col;
--gap: 2;
"
>
<img
src="https://images.unsplash.com/photo-1500382017468-9049fed747ef?auto=format&fit=crop&w=320&h=200&q=60"
width="320"
height="200"
loading="lazy"
alt="Savanna grass at dawn"
style="
--w: 100%;
--aspect: 1;
--bg: var(--color-muted);
--radius: 2.5;
--object-fit: fill;
"
/>
<figcaption
data-ui="text-xs"
style="
--font-weight: strong;
--text-align: center;
--text: var(--color-muted-foreground);
"
>
--object-fit: fill
</figcaption>
</figure>
</div>