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-canvas

Elevated surface container with background, radius, shadow, and padding. Use the data-canvas attribute on semantic elements or the layout-canvas wrapper element.

Overview

A canvas is a surface: a panel with a background, border radius, shadow and padding that sets a region of the page apart. Several canvases can sit on one page, side by side or nested.

Both forms consume the same --canvas-* design tokens used by data-backdrop, so theme overrides apply to both systems.

The surface always reserves a 1px edge. On a plain page, where the canvas and the page share --color-surface, the edge is a --color-border hairline so the panel reads in light and dark mode. Under data-backdrop the tinted page frames the surface and the edge is transparent. In forced-colours mode (Windows High Contrast) the edge is drawn in CanvasText.

Element and attribute forms

The attribute form is data-canvas, not data-layout="canvas", and the variant goes in its value: data-canvas, data-canvas="flush" or data-canvas="elevated". The element form is <layout-canvas> with data-variant. data-max, data-padding and data-canvas-depth work on both.

Which to choose: prefer data-canvas on the semantic element that already holds the content (<article>, <section>, <aside>, <form>). Use <layout-canvas> when several children with no common semantic parent need one surface. Note that main, article, section and aside are container-query containers, which <layout-canvas> is not.

Why not data-layout? A canvas is a surface, not a flow layout. VB keeps the two apart: flow primitives (stack, grid, reel…) use data-layout="…" with data-layout-* modifiers, and surfaces (canvas, card, badge) use bare data-* attributes such as data-max and data-padding. That way one element can be both: <article data-canvas data-layout="stack"> is a surface whose children stack.

Attributes

Attribute Values Default Applies to Description
data-canvas (bare), flush, elevated (bare) attribute Turns any element into a canvas. The value is the variant: bare for the default surface, flush (no radius or shadow) or elevated (larger radius and shadow, 37.5rem and wider). See data-canvas.
data-variant flush, elevated — element Variant for <layout-canvas>. Has no effect with data-canvas; put the variant in the data-canvas value instead. elevated applies at 37.5rem and wider.
data-max narrow, normal, wide, prose — both Max inline size, centered: narrow / normal / wide use the --content-narrow / --content-normal / --content-wide tokens (40 / 60 / 80rem by default; normal is fluid under data-fluid), prose is 65ch.
data-padding none, s, m, l, xl l both Padding on all sides. An explicit value is kept on narrow screens (see Mobile behavior).
data-canvas-depth 1, 2 — both Stacked-paper effect with 1 or 2 sheets behind the surface. 37.5rem and wider only; not on the flush variant.

Child attributes

None. Any content can go inside a canvas; a canvas nested in another canvas picks up the raised surface colour automatically.

Examples

Variants

flush drops the radius and shadow for an edge-to-edge surface; elevated adds a larger radius and stronger shadow for emphasis.

Width constraints

Use data-max to constrain the canvas width. It auto-centers with margin-inline: auto.

Padding

data-padding sets the padding on all sides, from none to xl (default l).

Nested canvases

Nested canvases automatically use --color-surface-raised for visual hierarchy. They do it by setting --canvas-bg, not background, so the depth sheets match the nested surface and an author's own --canvas-bg on the nested canvas still wins.

Ghost card depth

Add stacked-paper sheets beneath the canvas for a layered effect. Not available on the flush variant, and only drawn at 37.5rem and wider.

Multiple canvases

Unlike data-backdrop, which styles body-level regions implicitly, data-canvas works on any element, so you can have multiple independent canvases on the same page.

Relationship to data-backdrop

data-canvas and data-backdrop are complementary:

  • data-backdrop styles body > main/header/footer/nav/aside implicitly
  • data-canvas is for explicit, per-element canvas surfaces
  • Both consume the same --canvas-* tokens
  • A page can use both simultaneously

Token coupling

The --canvas-* tokens (--canvas-bg, --canvas-radius, --canvas-shadow, padding and width) are only defined under [data-backdrop]. Without a backdrop, every canvas uses the fallbacks (surface colour, --radius-l, --shadow-l). With one, the backdrop preset decides: <html data-backdrop="flush"> sets --canvas-radius: 0 and --canvas-shadow: none, which flattens every default data-canvas on the page too. The elevated variant reads --radius-xl and --shadow-xl directly, so it keeps its elevation under any backdrop preset. To restyle one canvas, set the --canvas-* tokens on that element.

Mobile behavior

Below 37.5rem (600px, --bp-s), every canvas goes flush — no border radius, no shadow (including the elevated variant and the depth sheets) — and fills the width with reduced inline padding (--size-m). Two exceptions: an explicit data-padding keeps its value, and an explicit data-max still caps the width (only prose, 65ch, is narrower than the breakpoint). The element and attribute forms behave the same. This matches data-backdrop mobile behavior.

Accessibility

  • A canvas is presentation only. It adds no role or name. Choose the element by meaning (<article> for standalone content, <aside> for related content, <section> with a heading for a region) and the surface follows; that is the main reason to prefer the attribute form.
  • Forced colours: Windows High Contrast removes backgrounds and shadows, so the canvas draws its edge in CanvasText and stays visible as a separate region.
  • Contrast: nested canvases use --color-surface-raised, a theme token designed to carry the theme's text colours. If you set --canvas-bg yourself, check the text contrast against it (4.5:1 for body text, WCAG 1.4.3).
  • Edges are not the only cue: on a plain page the 1px hairline marks the edge where the shadow is faint (dark mode). Give each canvas a heading as well, so the regions are distinct for screen reader users too.

Related

↑