Layouts
Let content size the layout first, then add a breakpoint only when the arrangement truly changes. The result works from a phone to a wall display, and in any language or reading direction.
When to use these rules
For every page and every component, because the headless layer ships no layout. The themes and your own CSS decide it, and these rules keep the two consistent.
When to leave them
A full-screen workspace, a canvas tool or an embedded third-party application may need its own layout. Keep the same accessibility floor: reflow, focus that is never hidden, and targets large enough to press.
Rules
- Start narrow. The base rules are the small-screen layout; queries add width with
min-width. - Size by content. Reach for
minmax(),clamp(),flex-wrapandauto-fitbefore a breakpoint. - Breakpoints in
rem, so they follow the reader’s font size. - Components ask their container; page shells ask the window.
- Logical properties (
inline-size,margin-inline) so right-to-left needs no second stylesheet. - No horizontal scrolling at 320 pixels, and none at 400 percent zoom. A wide table scrolls inside its own labelled region, never the page.
- Never
width: 100vwon a full-width block; it includes the scrollbar.
Breakpoints
| Name | From | What changes |
|---|---|---|
| Narrow | Base rules, no query | The default layout. Every page starts here, at 320 CSS pixels. |
| Wide | 48rem (768px at default size) | A sidebar appears, a list becomes a table, columns split. |
Spacing scale
Five steps, in rem, and two fluid values (--space-fluid-gutter, --space-fluid-section) that grow with the viewport between a floor and a ceiling. Bars below are drawn
with the tokens themselves.
--lily-space-xs0.25rem--lily-space-sm0.5rem--lily-space-md1rem--lily-space-lg1.5rem--lily-space-xl2rem
Line length
Five content-width tokens cap a line of text so it stays readable: --content-width-narrower, --content-width-narrow, --content-width-normal, --content-width-wide, --content-width-wider.
Components ask their container
A card should care about the room it is given, not the window. Drag the corner of the box below to resize it; the card changes arrangement at 30rem of its own width.
Adaptive card
Stacks when narrow and puts the media beside the text once its container is wide enough.
.card-host { container-type: inline-size; }
@container (min-width: 30rem) {
.card { display: grid; grid-template-columns: 8rem 1fr; }
} A grid that needs no breakpoint
.auto-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
gap: var(--lily-space-md);
} The five-region page
Many applications use one shell: a header, a left and a right aside, a main area and a footer. Lily’s grail layout components give it semantic landmarks; the theme decides when the asides collapse.
Check it
- Open the page at 320 pixels wide, then at 400 percent zoom. Nothing should need sideways scrolling.
- Set the text size to the largest step and switch to a right-to-left language.
- Fix a bar to an edge? Set
--lily-fixed-bar-block-endso a focused control is never hidden behind it.