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

data-page-layout

VB's page-template system. Put it on <body> and the semantic children (header, nav, main, aside, footer) auto-assign to named grid areas: no classes, no wrappers. Eight templates, sidebar width and gap modifiers, mobile collapse and an accessible dashboard drawer.

Overview

data-page-layout turns the page into a CSS grid where the semantic elements are the grid items: <header>, <nav>, <main>, <aside> and <footer> auto-register to named areas. The semantic markup you already have IS the layout.

It is VB's only page-template system. Use it on <body>; the rules are not body-scoped (except the wide-screen cap), so the same templates also work on a <section> — which is how the demos below preview them.

Usage

The children land in body-header, body-nav, body-main and body-footer automatically. Only direct children are placed.

Page layout vs data-layout

  • data-page-layout shapes the page: which region goes where, how they collapse on small screens. One per page, on <body>.
  • data-layout lays out a component: the children of any element (a stack inside <main>, a cluster in a <nav>, a grid of cards). Use it inside the page regions.

data-layout="holy-grail" and data-layout="dashboard" no longer exist: they were a second copy of these templates with different area names and widths. Use data-page-layout="holy-grail" / "dashboard". data-layout="regions" stays: it structures a component (a card's header/content/footer), not a page. For a sidebar inside the main region, use <main data-layout="sidebar-left|sidebar-right"> (see Grid Identity) or <layout-sidebar>.

Templates

Each template is a grid-template over named areas. The table shows the grid at 48rem and wider; sw is the sidebar width (16rem by default).

ValueAreas (rows / columns)Children placedNotes
stack (or bare data-page-layout) body-header / body-nav / body-main (1fr) / body-aside / body-footer; one column header, nav, main, aside, footer Content-first sites; also the mobile shape of the sidebar templates.
sidebar-left header across; body-nav | body-main; footer across. Columns sw 1fr header, nav, main, footer Docs sites, blogs. No <nav>: one column.
sidebar-right header across; body-main | body-aside; footer across. Columns 1fr sw header, main, aside, footer Articles with a TOC. No <aside>: one column.
holy-grail header across; body-nav | body-main | body-aside; footer across. Columns sw 1fr sw header, nav, main, aside, footer Classic three columns. Drops to two columns without the nav or the aside, one without both. Capped at 87.5rem on <body>.
app-shell body-nav spans both rows on the left; body-header above body-main (1fr). Columns auto 1fr nav, header, main Application chrome, gap: 0. On mobile the nav moves to the bottom.
dashboard header across; body-nav | body-main (1fr). Columns auto 1fr header, nav, main Admin and data-heavy UIs, gap: 0. On mobile the nav becomes a drawer. Capped at 87.5rem on <body>.
article body-header / body-main (1fr) / body-footer; one centred column, at most --content-normal wide header, main, footer Long-form reading pages.
landing body-header / body-nav / hero / body-main / feature / cta / body-footer; one column header, nav, main, footer, plus data-layout-area children Marketing pages; see named areas.

A child whose area the template does not define (an <aside> in sidebar-left, app-shell or dashboard; a <nav> in sidebar-right; a <footer> in app-shell or dashboard) gets an implicit grid track beside the template and lands out of place. Pick the template that has a slot for every region you use.

Semantic elements → grid areas

Direct childGrid area
<header>body-header
<nav> body-nav
<main> body-main
<aside> body-aside
<footer>body-footer
second <nav>body-nav-secondary — no built-in template defines it; add it in your own template override
<nav class="bottom">auto (escape hatch: flows into the next free cell)
any other elementauto-placed, unless it has data-layout-area

Modifiers

AttributeOnValuesEffect
data-layout-gaplayout hostnone, 3xs … 3xlGap between regions (default m; app-shell and dashboard default to 0).
data-layout-sidebar-widthlayout hostnarrow (12rem), normal (16rem), wide (20rem)Width of the sidebar columns. On app-shell and dashboard, whose nav column is otherwise sized to its content, it switches the column to that fixed width.
data-sidebarlayout hostcollapsed, hiddencollapsed narrows the sidebar columns to --sidebar-collapsed (default 4rem), for an icon rail; hidden hides the <nav> region and drops its column from the template (sidebar-left and holy-grail close up; no empty track is left).
data-layout-nowraplayout hostbooleanKeep the wide shape on small screens (no collapse, no drawer).
data-layout-stickyheader, nav, asidebooleanStick the region while the page scrolls; nav and aside scroll on their own when taller than the viewport. Requires <html data-sticky>.
data-layout-bleedany direct childbooleanSpan every grid column. Only works on direct children of the layout host (not the same as data-bleed, which breaks a child out of a text measure).
data-layout-areaany direct childhero, feature, ctaPlace the child in a named area of the landing template.

data-layout-order does not apply to page-layout children: every region has an explicit grid area, and order only moves auto-placed items. Change the template (or the source order) instead.

Custom properties

PropertyDefaultEffect
--sidebar-width16remDefault sidebar column width. Set it on the host, or on :root to inherit everywhere; the host resolves it into its own --_sidebar-width.
--sidebar-collapsed4remWidth used by data-sidebar="collapsed".
--tpl-stack, --tpl-sidebar-left, … --tpl-landingthe templates aboveReplace a template wholesale. Set it on the layout host (for example on body), not on :root: the templates are declared on the host.

Small screens, wide screens and print

  • Below 48rem, sidebar-left, sidebar-right and holy-grail collapse to the stack shape (header, nav, main, aside, footer). app-shell moves its nav below the main region as a bottom bar, with safe-area padding for notched devices. dashboard drops its nav column and turns the nav into a drawer. data-layout-nowrap on the host opts out of all of these.
  • At 87.5rem and wider, body[data-page-layout="holy-grail"] and body[data-page-layout="dashboard"] stop growing and centre.
  • Print: the grid becomes a single block, and the nav and aside regions are hidden.

Dashboard drawer

Below 48rem the dashboard nav is an off-canvas drawer: fixed to the inline-start edge, full height, as wide as the sidebar width (16rem by default) or 85vw, whichever is smaller. Open, it covers the header too, toggle included. While closed it is visibility: hidden, so its links are out of the tab order and the accessibility tree, not just moved off-screen. It slides in when it opens (instantly with reduced motion), from the right in right-to-left pages. An element with data-nav-toggle inside the layout is hidden at 48rem and wider, where the nav is a normal column.

No script: a native popover

Give the nav popover and an id, and point a button at it. The browser handles opening, Escape, light dismiss and focus return; from 48rem the nav renders as a normal column despite the popover attribute.

With script: data-nav-open

Or toggle data-nav-open on the layout host yourself. Keep aria-expanded on the button in sync and return focus to the button on close. The open drawer covers the header, toggle included, so the script must also close it on Escape and on a tap or click outside the nav (touch users have no Escape key), and the nav should carry its own close button.

Named areas

data-layout-area places a direct child in one of the extra areas of the landing template: hero, feature or cta. No other template defines extra areas; an area name the active template lacks creates an implicit zero-width track and the child disappears.

App shell

app-shell puts a vertical nav bar beside the header and main region, and moves it to a bottom tab bar on small screens.

Container queries

The regions carry container names so component CSS can adapt to the region it sits in:

  • <main> → region-main
  • <aside> → region-aside
  • <nav> → region-nav, where the nav column has a definite width: stack, sidebar-left, holy-grail, landing, and dashboard with data-layout-sidebar-width or data-sidebar="collapsed". In app-shell, a default dashboard and nav.bottom the nav is sized by its content, and making it a size container would collapse it.

For containers anywhere else, see data-container.

Accessibility

  • Landmarks come from the elements. As direct children of <body>, header and footer are the banner and contentinfo landmarks, and main, nav and aside are main, navigation and complementary. Name each nav and aside with aria-label when there is more than one. A section placed with data-layout-area is a region landmark only when named (aria-labelledby).
  • Reading order is source order. Grid placement does not change keyboard or screen-reader order. Write regions in reading order (header, nav, main, aside, footer). In app-shell on small screens the nav is drawn as a bottom bar but is still read before the main content; a skip link to <main> keeps that quick to pass.
  • Dashboard drawer. Closed, the nav is hidden from everyone (visibility: hidden), so focus cannot land on invisible links. The toggle must be a real <button> with a visible label; with the data-nav-open pattern, keep aria-expanded and aria-controls on it, close on Escape and on an outside tap, offer a close button inside the nav, and return focus. The popover pattern does all of this natively.
  • Motion. The drawer slides only when the user has not asked for reduced motion.
  • Sticky regions (data-layout-sticky) are capped at the viewport height and scroll on their own, so every link stays reachable; anchor jumps land below a sticky header (see data-sticky).

Why a body-level attribute (not a custom element)

A page shell is not a wrapper — it is the page. Wrapping the body's contents in a <page-shell> element would turn the header and footer into children of a generic element instead of the body. The attribute form keeps the document structure intact and adds the grid on top.

Related

↑