Theme
On this page (9)

§A small surface over native layout

Use short, familiar classes for common operations; keep configuration properties descriptive. flex selects Flexbox and grid selects Grid. Neither silently chooses a gap, wrapping or columns. More opinionated composition is explicit.

ClassContract
flex / inline-flexFlex formatting context; native row and nowrap defaults.
grid / inline-gridGrid formatting context; no prescribed tracks.
stackFlex column; default gap of four density-adjusted base units.
containerCentered border-box container; 80rem maximum; inline gutters.
centerGrid with centered items; no implicit viewport height.
queryNamed layout inline-size query boundary.

A stack of a flex row and an intrinsic grid - switch the card to Phone or Tablet to watch both halves re-flow.

§Let available space do the work

Use wrapping Flexbox for one-dimensional content and an intrinsic Grid for equal-width cards - the two halves of the composition demo above, which reacts when you resize it with the width toolbar. A grid can adapt inside a sidebar, dialog or full page without viewport breakpoints. Use container queries only when the structure must change.

<!-- One-dimensional content: wrap with the available width. -->
<div class="flex flex-wrap items-center justify-between gap-3">…</div>
<!-- Equal-width cards: intrinsic auto-fit grid, no breakpoints. -->
<div class="grid grid-cols-auto gap-4" style="--layout-min:12rem;">…</div>

§Handle overflow deliberately

Every constrained container eventually overflows; the question is only which policy you choose. The overflow family covers the box axes, truncate bundles the classic single-line ellipsis recipe, and the break/wrap family decides what happens to words that don't fit - wrap-anywhere is the flex min-w-0 companion that lets a long identifier wrap inside a shrinkable track.

ClassContract
overflow-auto / -x-auto / -y-autoScroll the box on the chosen axes.
overflow-hidden / -x-hidden / -y-hiddenClip at the padding edge, no scrolling.
overflow-clip / overflow-visibleHard clip (no scrollable overflow area at all) / the native default.
truncateoverflow-hidden + text-overflow:ellipsis + nowrap in one class.
text-ellipsis / text-clipHow an overflowing inline box ends - needs an overflow context.
break-words / break-all / break-normalWord-breaking policy: break on demand, break anywhere per character, native.
wrap-anywhereoverflow-wrap:anywhere - also shrinks min-content, the partner of min-w-0.

Three overflow policies at work - shrink the canvas (Phone) and watch each box react on its own axis.

§Guides

Each primitive has its own page with rendered demos and the full class reference:

§Each primitive owns its parameters

PropertyOwner / default
--layout-gapFlex/grid/stack/center instance; resets at each nested root.
--layout-minGrid instance; 16rem preferred auto-fit track minimum.
--layout-maxContainer instance; 80rem outer maximum.
--layout-gutterContainer instance; four density-adjusted base units.

An outer grid’s track minimum must not accidentally configure an inner grid. Defaults are declared on each owning root; override that root with inline properties or unlayered application CSS. An explicit helper such as gap-2 takes precedence over a primitive’s default gap.

.project-grid { --layout-min: 18rem; --layout-gap: 1.25rem; }
.reading-area { --layout-max: 70ch; --layout-gutter: clamp(1rem, 3vw, 2rem); }

§Familiar names, not a Tailwind compiler

Numeric sizing, spacing, alignment, flex and fixed-grid names follow familiar Tailwind conventions at the default scale. stack, center, query, grid-cols-auto and the centered/guttered container are deliberate extensions. There are no arbitrary-value brackets, generated breakpoint prefixes, class scanning or runtime layout scripts. Use ordinary CSS for exceptional layouts.

Generic names can collide with other utility libraries. This module is optional; layers control precedence, not selector isolation. Documentation previews use separate documents so the legacy, unlayered docs utilities cannot mask the public CSS.

§Keep semantics and reading order

CSS Grid does not imply an ARIA grid widget. Preserve meaningful DOM order; no dense placement or visual-reordering helpers are shipped. Display helpers leave native hidden elements, until-found content, closed dialogs and closed popovers under native control. Long content still needs an explicit wrapping or scrolling policy; the module does not hide overflow.

§Load the optional modules

<link rel="stylesheet" href="../theme/utils/default-semantic-tokens.css">
<link rel="stylesheet" href="../theme/utils/sizing.css">
<link rel="stylesheet" href="../theme/utils/layout.css">
<link rel="stylesheet" href="../theme/utils/accessibility.css">
<!-- Load the component stylesheets you actually use next. -->
<link rel="stylesheet" href="../components/button/button.css">

§Platform references

CSS Grid and subgrid · CSS Flexible Box Layout · CSS container queries · HTML hidden states

Comments, ideas or improvements? Edit this page's source on GitHub