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

Content Width

How to stop content stretching across a wide screen: width caps for sections, a reading measure for text, newspaper columns and children that break out to full width.

Two kinds of cap

A page that fills a wide monitor is hard to read. Vanilla Breeze caps width in two ways, for two kinds of content.

Content width Measure
ForA section of mixed content: cards, forms, a heroRunning text: an article, documentation, a letter
Unitremch, so the cap is a number of characters per line
Tokens--content-narrow (40rem), --content-normal (60rem), --content-wide (80rem)--measure-narrow (45ch), --measure-normal (65ch), --measure-wide (80ch)
Layout<layout-center><layout-text> or data-layout="prose"
PositionCenteredAt the start edge, unless you add data-layout-centered
Also doesAdds a gutter on each side so content does not touch the screen edgeSpaces headings, paragraphs, lists and figures

Capping a section

<layout-center> limits its width and centers itself in its parent. data-layout-max picks the cap.

data-layout-maxCap
narrow40rem
normal (default)60rem
wide80rem
prose65ch

The gutter is added outside the cap, so a normal center holds 60rem of content plus the gutters. data-layout-gutter sets it to none, s or l; the default is m.

Add data-layout-gap and the center also spaces its children in a column, which saves nesting a stack inside it.

Two more modifiers: data-layout-intrinsic centers children that are narrower than the cap, and data-layout-text centers the text.

Capping text

Lines of 45 to 80 characters are comfortable to read. <layout-text>, or data-layout="prose" on an element such as <article>, holds text to that length and sets the vertical rhythm: more space before a heading than after it, extra room around figures, tables and code.

The demo changes the measure. The figure is covered in Breaking out.

data-layout-maxMeasure
narrow45ch
normal (default)65ch
wide80ch

The same words mean different widths on a center and on text: narrow is 40rem on <layout-center> and 45ch on <layout-text>.

When the nearest container is under 30rem wide, the cap is released and text fills the width.

Width without the rhythm

data-measure on an <article> caps and centers it and changes nothing else. Use it when the article's children already manage their own spacing. Values: bare (65ch), narrow, wide.

Text in columns

<layout-columns> flows text across columns, like a newspaper. It shares the measure and rhythm of <layout-text>.

data-layout-column-countResult
1One column
2, 3Up to that many columns. Fewer when a column would be narrower than 14rem.
autoAs many columns as fit, each one measure wide (or --column-min-width, 38ch, when no measure is set)

With a measure set, the block is capped at the column count times the measure. Lists, figures, tables and quotations are kept whole and not split across a column break, and a heading stays with the text after it.

Breaking out

A wide table or a photograph often wants more room than the text around it. Put data-bleed on a direct child of a text container and that child ignores the measure. It runs the full width of the nearest query container, which is usually the <main>, <section> or <article> the text sits in.

  • It works in <layout-text>, data-layout="prose", <layout-columns>, data-layout="columns" and article[data-measure].
  • The child must be a direct child. A figure inside a nested section stays at the measure.
  • In columns, the child spans every column.
  • The width is the container's, not the viewport's, so a bleed inside a page with a sidebar stops at the edge of the content area.

Other places a cap is set

On How Cap
<main>class="narrow"The normal measure, centered
<main>class="contained"1200px, centered
<main>class="wide"1600px, centered
<layout-card>, <layout-canvas>data-maxnarrow, normal, wide (the content widths) or prose (65ch)
data-page-layout="article"The templateOne centered column of --content-normal

Changing the caps

Set the tokens to change every place that reads them.

Under data-fluid, the fluid preset sets --content-normal and --measure-normal so that they grow with the viewport. The library's styles sit in cascade layers and your own unlayered CSS outranks them, so a rule like the one above fixes the two tokens at your values and the preset no longer moves them.

↑