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

Typographic content container with vertical rhythm. Provides intelligent spacing between paragraphs, headings, lists, and other block elements.

Overview

The layout-text element creates a container optimized for long-form reading content. It:

  • Sets a maximum line width of --measure-normal (65ch by default; data-fluid makes it fluid, and the dyslexia and large-text themes shorten it)
  • Applies consistent vertical spacing between block elements
  • Uses larger margins before major headings (proximity principle)
  • Tightens spacing after headings so they associate with their content
  • Provides extra breathing room around figures, pre, code-block, tables, blockquotes, video and browser-window

The rhythm applies between direct children. Content wrapped in one extra element (a single <article> inside) only gets the browser's default spacing; put the content straight inside, or use the attribute form on the article itself.

Element and attribute forms

The same typographic core (measure, rhythm, centering, bleed) is available without a wrapper element. The attribute value is prose, not text: there is no data-layout="text".

  • data-layout="prose": identical to <layout-text>. Spell the measure data-layout-max or data-layout-measure; both work on both forms.
  • data-layout="columns": adds multi-column flow; see <layout-columns>.
  • article[data-measure]: the reading width only, always centered, with no rhythm. See Reading width only.

Which to choose: when the text already lives in an <article> or <section>, put data-layout="prose" on it: no wrapper, and its headings and paragraphs are direct children, so the rhythm reaches them. Use <layout-text> when there is no such element, for example inside a sidebar layout's content slot. In the attribute form, main, article, section and aside are also container-query containers, which the element is not (that matters for data-bleed). See data-layout for the full comparison.

Attributes

Every row applies to <layout-text> and [data-layout="prose"], and also to <layout-columns> and [data-layout="columns"], which share the typographic core.

Attribute Values Default Applies to Description
data-layout-measure narrow, normal, wide normal both Line measure: --measure-narrow / --measure-normal / --measure-wide (45 / 65 / 80ch by default). See Measure.
data-layout-max narrow, normal, wide normal both Same as data-layout-measure. ch-based: narrow is 45ch here but 40rem on layout-center.
data-layout-centered (boolean) — both Center the container (margin-inline: auto). Off by default: the text keeps its position.

Child attributes

AttributeOnDescription
data-bleed a direct child Break out to the full width of the nearest query container. Also works on direct children of article[data-measure]. See Full-width breakout.

Measure

The default line width is --measure-normal. data-layout-measure (or data-layout-max) picks narrow, normal or wide. The tokens are 45, 65 and 80ch by default. Under data-fluid they become clamps that grow with the viewport, and the accessibility themes adjust them (dyslexia 55ch, large text 60ch).

Narrow containers: in a query container narrower than 30rem (a sidebar, a card, a phone-width column), the measure is released to 100%, so the text fills the space rather than leaving a gap.

Reading width only: article[data-measure]

For an article that needs the reading width but not the rhythm, use data-measure on the <article>. It is always centered. Bare or normal uses --measure-normal; narrow and wide use the other two tokens. data-bleed works on its direct children too.

It is not a data-layout value and only works on <article>. Choose it when the content brings its own spacing (a CMS body with its own styles, a stack of components) and you only want the line length; choose data-layout="prose" when you also want the rhythm. Unlike the prose and columns forms, data-measure is not released to the full width in narrow containers.

Spacing rules

layout-text spaces its direct children according to their element type:

Context Spacing Rationale
Default (between elements) var(--size-m) Standard paragraph spacing
Before h2 var(--size-2xl) Major section break
Before h3 var(--size-xl) Subsection break
Before h4/h5/h6 var(--size-l) Minor section break
After any heading var(--size-s) Associates heading with content
Between consecutive lists var(--size-s) Groups related lists
Before/after figure, pre, table, blockquote, video, code-block, browser-window var(--size-l) Extra breathing room for media

Examples

Vertical rhythm

Centering

layout-text keeps its position by default. Add data-layout-centered to center it in its container. Since it already limits its own width, it needs no layout-center wrapper.

Full-width breakout

Add data-bleed to a direct child (a figure, a table, a code block) to break it out of the measure. The child spans the full width of the nearest query container: main, article, section and aside are query containers by default, as is any element with data-container. (Not to be confused with data-layout-bleed, which spans a direct child of a data-page-layout grid across every column.)

  • It works centered or not. Uncentered text bleeds from its start edge across the container; centered text bleeds evenly on both sides.
  • It measures the container, not the viewport, so it never adds a horizontal scrollbar.
  • If the text host is itself a query container (<article data-layout="prose">, article[data-measure]), it stops being one while it holds a bleed child, so the bleed reaches the next container out. Add data-container to the host to keep it as a container (the bleed then fills only the host).
  • With no query container above it at all, the bleed falls back to the viewport width.
  • In layout-columns, a bleed child also spans every column.

Blog post

The article is the reading container: data-layout="prose" with a narrow measure, centered. No wrapper elements.

Documentation page

Inside a sidebar layout there is no article to carry the attribute, so the element form fits. The measure is released to the full width when the content column gets narrower than 30rem.

Best practices

  • Use for long-form content only - layout-text is designed for articles, documentation, and similar content. Don't use it for UI layouts.
  • Center with data-layout-centered - layout-text already limits its own width, so it doesn't need a layout-center wrapper to constrain it. Use layout-center only when the page needs a wider frame around the text. Note that the two data-layout-max attributes use different scales: narrow is 40rem on layout-center and 45ch on layout-text.
  • Semantic HTML - The spacing rules work best with proper semantic markup (h2 before h3, etc.).
  • Avoid nesting layout elements - layout-stack, layout-grid, and similar elements inside prose may have unexpected spacing.

Accessibility

  • Line length: the measure keeps lines between roughly 45 and 80 characters, the range that is easiest to track from one line to the next. WCAG 1.4.8 Visual Presentation (AAA) recommends no more than 80.
  • Reader preferences: the dyslexia and large-text themes shorten the measure tokens (55ch and 60ch), and line height comes from --prose-line-height (1.6 by default), which those themes and user settings can raise. Set spacing through these tokens rather than fixed values so the preferences reach your text.
  • Zoom and reflow: the measure is in ch, so it grows with the text size, and it is released to the full width in containers narrower than 30rem, so enlarged text reflows instead of overflowing (WCAG 1.4.10 Reflow).
  • Structure: the rhythm follows the heading levels, so use them in order (h2 before h3) and the visual hierarchy matches what screen readers announce.

Related

↑