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

Fluid Scaling

Type and spacing that grow smoothly with the viewport, with no breakpoints. One attribute turns it on, and three presets set how far the sizes move.

What it does

By default the type and spacing tokens are fixed: --font-size-5xl is 3rem on a phone and on a wide monitor. With data-fluid, each token becomes a clamp() value that grows with the viewport between 320px and 1440px wide. Below 320px it holds at its smallest value and above 1440px at its largest.

Because the change is in the tokens, everything that reads them follows: headings, body text, layout gaps, padding. There is no step where sizes jump.

Choose a preset in the demo, then resize the window. The line under the specimen shows two of the computed sizes.

Turning it on

Add data-fluid to <html>. It is off unless you add it.

The attribute also works on any other element and then applies to that subtree only. The sizes still follow the width of the viewport, not the width of the element.

To let readers choose, the <settings-panel> has a fluid scaling control that sets the attribute and remembers the choice. From script, use the theme manager.

Presets

Each range runs from the value at a 320px viewport to the value at 1440px.

Token Fixed compact data-fluid spacious
Ratio between type stepsVaries1.067 to 1.21.125 to 1.251.2 to 1.333
--font-size-m (body text)1rem1rem1rem to 1.06rem1rem to 1.13rem
--font-size-5xl3rem1.48rem to 2.99rem2.03rem to 4.05rem2.99rem to 6.31rem
--size-unit (spacing)0.25rem0.2rem to 0.25rem0.225rem to 0.275rem0.25rem to 0.3125rem
--content-normal60rem40rem to 60rem40rem to 65rem42rem to 70rem
--measure-normal65ch55ch to 65ch55ch to 70ch55ch to 75ch
  • compact keeps headings close in size to the text and spacing at or below the fixed scale. It suits dense screens such as dashboards.
  • The default is a moderate range that suits most content sites.
  • spacious gives large headings and looser spacing on wide screens. It suits landing pages and editorial layouts.

What changes

Type

Nine tokens, --font-size-xs to --font-size-5xl, are replaced. From the body size up, each gets a clamp() value. The steps are closer together on a narrow viewport, where a very large heading would wrap badly, and further apart on a wide one. The large sizes move the most and body text hardly moves.

No size gets smaller as the viewport widens. The two steps below the body size, --font-size-xs and --font-size-s, keep one value at every width in the default and compact presets. In spacious, --font-size-xs is constant and --font-size-s grows slightly.

--font-size-2xs stays fixed. The fixed scale and the rest of the type system are described in the Typography guide.

Spacing

Only --size-unit is replaced. The nine --size-* tokens are multiples of it, so the whole spacing scale becomes fluid: data-layout-gap, layout padding and the data-layout-density scales.

Content widths

--content-normal and --measure-normal grow with the viewport, so a centered column and a reading column are narrower on small screens and wider on large ones. The narrow and wide variants stay fixed. See Content Width.

What does not change

  • Breakpoints. The widths where page layouts, main-level sidebars and splits collapse (48rem) are media queries and stay where they are.
  • Layout thresholds. Grid column minimums, the switcher threshold and sidebar widths are fixed rem values.
  • Line height, colors, radii and shadows.

With themes

data-fluid combines with data-theme. Most themes set colors and fonts and leave sizes alone, so nothing more is needed.

The a11y-large-text theme raises the base sizes (body text at 1.25rem, a spacing unit of 0.3125rem). It has its own fluid values, so with data-fluid the body text runs from 1.25rem to 1.375rem and the larger sizes scale from that base. The named presets work with it too: compact and spacious give that preset's type and spacing values multiplied by 1.25.

A preset of your own

A preset is a rule that sets the tokens. Write one with your own values and name it in the attribute. Each value is clamp(minimum, slope + intercept, maximum); use vi for the slope so it follows the inline size of the viewport.

Tokens you leave out keep the default preset's values, because [data-fluid] matches any value. The library has no tool that generates these values.

Input type

Two adjustments depend on the pointer and not on the viewport. They are always on and do not need data-fluid.

QueryEffect
(pointer: coarse)Buttons, selects and inputs get a minimum height of --size-touch-min (2.75rem, 44px). Their width and links are not changed.
(hover: none)The hover motion tokens --motion-hover-lift and --motion-hover-scale are set to none, so effects built on them do nothing on devices that cannot hover.

When to leave it off

  • Dense application screens. A dashboard or data table usually wants the same sizes at every width. Use fixed tokens, with data-layout-density="compact" if you want them tighter.
  • Embedded widgets. The sizes follow the viewport. A component that lives in a narrow column of a wide page gets wide-page sizes. Container queries suit that case better.
  • A site that already sizes type at breakpoints. Two systems moving the same sizes are hard to reason about. Pick one.
↑