Vanilla Breeze v0.7.4

Vanilla Breeze v0.7.4 released

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…

Read the release notes

layout-cluster

Horizontal flex layout with wrapping. Ideal for groups of inline elements like buttons, tags, and navigation items.

Overview

A cluster lays its children out in a row and wraps them onto new lines when they run out of room, with an even gap in both directions. It is a wrapping flex row (display: flex; flex-wrap: wrap) whose items keep their own content width.

By default the gap is s, items are vertically centred (align-items: center) and packed at the start of the line. Because items are content-sized, direct main, article, section and aside children drop their query-container status, which would otherwise collapse them to zero width; data-container opts one back in.

Element and attribute forms

Any element can be a cluster with data-layout="cluster". The same data-layout-* modifiers work on both forms; the two below lay out identically. The attribute form on a <ul> also tells screen readers how many items there are.

Which to choose: use the attribute form when a semantic element already wraps the items: a <nav>, <ul>, <footer> or <menu>. Use <layout-cluster> when there is no meaningful element to carry it 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 cluster resolve against it. See data-layout for the full comparison and Semantic Layouts for the approach.

Attributes

Attribute Values Default Applies to Description
data-layout-gap none, 3xs, 2xs, xs, s, m, l, xl, 2xl, 3xl s both Gap between items, on the shared size scale.
data-layout-justify start, end, center, between start both Main-axis distribution.
data-layout-align start, end, center, stretch, baseline center both Cross-axis alignment.
data-layout-nowrap (boolean) — both Keep everything on one line; no wrapping. See No wrap.
data-layout-overlap (bare), xs, s, m, l s both Overlap items (avatar groups) in DOM order, later items on top, each with a surface-coloured ring. Each item after the first is pulled back by xs 0.25rem, s 0.5rem, m 0.75rem or l 1rem. Forces gap 0. Bare attribute = s.

Child attributes

Attribute On Applies to Description
data-container main, article, section, aside both Opt a semantic child back into container queries. The layout removes container-type from such children so they size to content; this restores it (give the child an explicit inline size, or it collapses).

Examples

Gap

The data-layout-gap attribute controls spacing between items.

Justify

The data-layout-justify attribute controls horizontal distribution.

Align

The data-layout-align attribute controls vertical alignment.

No wrap

data-layout-nowrap keeps every item on one line. Items no longer wrap, so in a narrow container they overflow; give the cluster (or its parent) overflow-x: auto so the overflow scrolls instead of spilling out. Use it for short toolbars and breadcrumbs that must stay on one line.

Overlap

The data-layout-overlap attribute overlaps the items, for avatar groups and stacked chips. Items stay in DOM order, so what sighted users see matches reading and focus order; each later item stacks above the one before it, and a hovered or focused item is lifted to the top.

  • Overlap sizes. Each item after the first is pulled back by xs 0.25rem, s 0.5rem (the bare attribute), m 0.75rem or l 1rem.
  • Gap is forced to 0. The overlap comes from negative inline margins, so data-layout-gap has no effect.
  • Surface-coloured ring. Each item gets a 2px box-shadow ring in var(--color-surface) to separate it from its neighbour. In the list form, <user-avatar> draws the same ring itself, because the square <li> would otherwise carry it.

Mark an avatar group up as a list, as on the <user-avatar> page (Avatar Group): one <li> per person, the list named by a visible heading with aria-labelledby, and an aria-label on the +N chip that says what it stands for.

On a background other than --color-surface, match the ring to it by re-declaring the token on the group. That recolours the separator on every item, including the ring that <user-avatar> draws in the list form:

Button group

Tag cloud

Card footer actions

Navigation

The navigation is a real <nav> landmark carrying the layout through data-layout="cluster" — no extra wrapper.

Accessibility

  • The cluster never reorders items, and data-layout-justify only moves free space around, so reading and focus order are the DOM order.
  • When the items are a set (tags, avatars, links), use the attribute form on a <ul> or <menu> so screen readers announce the number of items. <layout-cluster> has no role of its own.
  • Give overlapping avatars a name each (alt or aria-label) and label the +N chip with what it stands for; the overlap hides part of each avatar, so the picture alone is not enough.
  • Wrapping is what lets a cluster reflow at high zoom (WCAG 1.4.10 Reflow). With data-layout-nowrap, make sure the overflow can scroll and every item can still be reached by keyboard.

Related

↑