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…
Vertical stacking layout with configurable gap. The fundamental building block for vertical rhythm.
Overview
A stack puts its children in a single column with a consistent gap between them. It is a flex column (display: flex; flex-direction: column) with no other spacing: children lose nothing and gain nothing except the gap.
The stack declares no align-items of its own, so children get the flex default, stretch: each one fills the stack's width. data-layout-align changes that; with start, center or end each child shrinks to its content.
Element and attribute forms
Any element can be a stack with data-layout="stack". The same data-layout-* modifiers work on both forms; the two below are identical.
Which to choose: use the attribute form when a semantic element already holds the column: a <form>, an <article>, a <section> or a list. Use <layout-stack> when there is no such element and you would otherwise add a wrapper, for example to group a label and its input inside a larger form. In the attribute form, main, article, section and aside are also container-query containers, which the element is not, so container queries inside the stack resolve against it. See data-layout for the full comparison and Semantic Layouts for the approach.
When the stack is aligned start/center/end, keeps the child as a query container. Give it an explicit inline size too, or it collapses.
Examples
Gap
The data-layout-gapattribute controls the spacing between stacked items.
Gap variants example
12345678910111213
<layout-stackdata-layout-gap="xs"><p>Item 1</p><p>Item 2</p><p>Item 3</p></layout-stack><layout-stackdata-layout-gap="m"><!-- Default gap --></layout-stack><layout-stackdata-layout-gap="xl"><!-- Large gap --></layout-stack>
Alignment
The data-layout-alignattribute controls the inline alignment of items.
VB makes main, article, section and aside query containers (container-type: inline-size). A query container has no intrinsic width, so in a stack aligned start, center or end, where children shrink to their content, it would collapse to zero width. The stack therefore removes container-type from such direct children so they size to their content. To keep container queries on one of them, add data-container and give it a width.
Aligned stack with sectioning children
12345678910
<layout-stackdata-layout-gap="s"data-layout-align="center"><section><p>A section sized to its content</p></section><article><p>An article too</p></article></layout-stack><sectiondata-layout="stack"data-layout-gap="s"data-layout-align="end"><article><p>End-aligned article</p></article><!-- data-container keeps container queries; it needs a width --><asideclass="container-panel"data-container><p>Container aside</p></aside></section>
<layout-stackdata-layout-gap="xl"><layout-stackdata-layout-gap="s"><h3>Section 1</h3><p>Content for section 1</p></layout-stack><layout-stackdata-layout-gap="s"><h3>Section 2</h3><p>Content for section 2</p></layout-stack></layout-stack>
A nested stack starts from its own defaults: a bare inner stack gets the m gap, not its parent's.
Accessibility
The stack changes spacing only. It never reorders children, so reading and focus order are the DOM order.
<layout-stack> has no role and is ignored by assistive technology. When the group has meaning (a form, a list, an article), use the attribute form on that element so its semantics stay without an extra wrapper.
Children reflow with the column, so text zoom and narrow viewports need no extra handling (WCAG 1.4.10 Reflow).
Related
data-layout — The attribute form (data-layout="stack") and every layout modifier