0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…
Auto-fit responsive grid layout. Creates equal-width columns that automatically reflow based on available space.
Overview
A grid fits as many equal-width columns as its width allows, then wraps the rest onto new rows. It is a CSS grid with grid-template-columns: repeat(auto-fit, minmax(min(var(--_min), 100%), 1fr)): every column is at least the minimum width (15rem by default) and the columns share any leftover space equally.
The column count depends on the grid's own width, not the viewport, so the same grid shows more columns in a wide main area than in a narrow sidebar. Items flow in source order, row by row.
Element and attribute forms
Any element can be a grid with data-layout="grid". The same data-layout-* modifiers work on both forms; the two below produce the same columns. A list of items is a natural fit for the attribute form on a <ul>.
Which to choose: use the attribute form when the grid is already a semantic element: a <ul> of products, a <section> of features. Use <layout-grid> when there is no such element and you would otherwise add a wrapper. In the attribute form, main, article, section and aside are also container-query containers, which the element is not, so container queries inside the grid resolve against it. See data-layout for the full comparison and Semantic Layouts for the approach.
Minimum column width before wrapping: 8 / 10 / 15 / 20 / 25rem. Tracks are clamped to the container, so a grid narrower than the minimum shows one full-width column instead of overflowing. One-off lengths: see the escape hatch.
data-layout-gap
none, 3xs, 2xs, xs, s, m, l, xl, 2xl, 3xl
m
both
Gap between cells, on the shared size scale.
data-layout-subgrid
(bare), 2, 3, 4
3 (bare)
both
Each child becomes a subgrid spanning that many rows so header/content/footer align across cells. Bare means 3; any other value also spans 3. See Subgrid.
Custom properties
Property
Default
Description
--layout-min
(unset)
A minimum column width that beats data-layout-min, set inline: style="--layout-min: 220px". Registered with inherits: false, so a nested grid does not pick it up. <layout-cover> reads the same property as its minimum height.
Child attributes
Every direct child is a cell. With data-layout-subgrid, each child's own direct children become its rows.
With data-layout-subgrid, these children are not query containers, so they can be subgrids. data-container restores the container; the child then sizes its own rows.
Examples
Minimum width
The data-layout-minattribute sets the minimum width each column can shrink to before the grid reflows.
Each track is minmax(min(min-width, 100%), 1fr). In a container narrower than the minimum (an xl grid in a 300px sidebar, or on a phone) the grid shows one column at the container's width instead of overflowing.
One-off widths: --layout-min
When none of the tokens fit, set --layout-min inline on the grid, as in the last example above. It beats the data-layout-min token. It is registered as non-inheriting, so a grid nested inside goes back to its own token or the default. <layout-cover> uses the same property for its minimum height.
With data-layout-subgrid, each child becomes a grid whose rows are subgrid. The child spans 3 rows (bare or "3"), 2, or 4. A header that wraps to two lines in one card then pushes the body row down in every card on that row, so titles, bodies and footers line up.
Give each child as many direct children as rows: header, section and footer for the default 3, title and body for 2.
The subgridded rows use the grid's row gap. data-layout-gap sets both the space between cards and the space between the parts inside each card. To space the parts differently, set row-gap on the children.
<layout-card> children with header/section/footer drop their own row template and follow the subgrid.
Any element can be the child: <layout-card>, <li>, or <article>/<section>. VB normally makes main, article, section and aside query containers; as direct children of a subgrid layout they are not, because the layout containment a query container needs would make them independent grids. A child with data-container keeps its container and sizes its own rows instead.
Browsers without subgrid fall back to cards that size their own rows.
Subgrid example
12345678910111213141516171819202122
<layout-griddata-layout-min="s"data-layout-subgrid><layout-carddata-variant="outlined"><header><h3>Starter</h3></header><section><p>One project.</p></section><footer><p>Free</p></footer></layout-card><!-- More cards; their rows line up --></layout-grid><!-- Two-row children, attribute form --><ulclass="unstyled"data-layout="grid"data-layout-min="s"data-layout-gap="m"data-layout-subgrid="2"><li><h3>Title</h3><p>Body</p></li><li><h3>A much longer title that wraps onto a second line</h3><p>Body</p></li><li><h3>Short</h3><p>Body</p></li></ul><!-- Article children align too --><layout-griddata-layout-min="s"data-layout-gap="m"data-layout-subgrid="2"><article><h3>Release notes</h3><p>Body</p></article><article><h3>Migration guide for the new page templates</h3><p>Body</p></article><article><h3>FAQ</h3><p>Body</p></article></layout-grid>
Gap
The data-layout-gapattribute controls spacing between grid items.
Gap variants
12345678910
<layout-griddata-layout-min="xs"data-layout-gap="xs"><layout-carddata-padding="s">1</layout-card><layout-carddata-padding="s">2</layout-card><layout-carddata-padding="s">3</layout-card><layout-carddata-padding="s">4</layout-card></layout-grid><layout-griddata-layout-min="xs"data-layout-gap="l"><!-- Same cells, larger gap --></layout-grid>
Product grid
Product grid example
123456789101112
<layout-griddata-layout-min="m"data-layout-gap="l"><layout-carddata-variant="outlined"><layout-stackdata-layout-gap="s"><figuredata-mediadata-ratio="4:3"data-radius="s"><imgsrc="product.jpg"alt="Product"loading="lazy" /></figure><h4>Product Name</h4><p>$29.99</p></layout-stack></layout-card><!-- More products... --></layout-grid>
Feature cards
Feature cards example
1234567891011121314151617181920
<layout-griddata-layout-min="l"data-layout-gap="m"><layout-card><layout-stackdata-layout-gap="s"><strong>Fast Performance</strong><p>Optimized for speed with minimal overhead.</p></layout-stack></layout-card><layout-card><layout-stackdata-layout-gap="s"><strong>Accessible</strong><p>Built with WCAG guidelines in mind.</p></layout-stack></layout-card><layout-card><layout-stackdata-layout-gap="s"><strong>Progressive</strong><p>Works without JavaScript, enhances with it.</p></layout-stack></layout-card></layout-grid>
Stats grid
Stats grid
123456789101112131415
<layout-griddata-layout-min="s"data-layout-gap="m"><layout-carddata-variant="outlined"data-padding="l"><layout-stackdata-layout-gap="xs"data-layout-align="center"><strong>1,234</strong><small>Total Users</small></layout-stack></layout-card><layout-carddata-variant="outlined"data-padding="l"><layout-stackdata-layout-gap="xs"data-layout-align="center"><strong>567</strong><small>Active Today</small></layout-stack></layout-card><!-- More stats... --></layout-grid>
Accessibility
Items flow in source order, left to right and then row by row (right to left in RTL pages), so reading and focus order match what is on screen. Don't reorder cells with order or explicit grid placement.
When the cells are a collection (products, team members, features), use the attribute form on a <ul> so screen readers announce how many items there are. <layout-grid> has no role of its own.
Keep heading levels inside cells consistent with the page outline; subgrid alignment is visual only.
The column count follows the grid's width, so at high zoom the grid drops to fewer columns instead of scrolling sideways (WCAG 1.4.10 Reflow).