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

Styling Overview

How Vanilla Breeze styles a page, what you get without writing CSS, and where to make a change: a theme, a token, a class or a rule of your own.

The approach

Vanilla Breeze styles HTML elements by their tag. A <button>, a <table> and a <blockquote> are styled as soon as the stylesheet loads, with no class on any of them. Four parts do the work:

Part What it is Where it lives
Tokens Custom properties for every color, size, radius, shadow, font and duration. Element rules read tokens and hold no values of their own. Tokens reference
Element rules Selectors on tags and custom elements. A class names a variant of one element (button.secondary), and a data-* attribute carries a setting with a value (data-layout-gap="l"). Elements, class
Themes A named set of token values, applied with data-theme on the page or on one element. Themes
Cascade layers Every library rule sits in a named @layer. A rule you write outside a layer wins over them, whatever its specificity. Overrides

What is handled and what you provide

Area The library handles You provide
Color Surface, text, border, brand and status colors, each with a light and a dark value; hover and active shades derived from the brand color Your brand hue or a theme, and the contrast of any color you add
Type A size scale, line heights, wrapping, heading and prose refinements, system font stacks A typeface, if you want one other than the system fonts
Space One spacing scale used by every element and layout, with compact and spacious settings The gap you want in each layout, chosen from the scale
Shape and depth Border widths, a radius scale, an elevation scale, opt-in shapes and shadow effects Nothing, unless you want a different corner or shadow
Surfaces Background tokens for page, panel, raised and sunken areas; translucent and paper surface types The choice of surface for a region
Motion Duration and easing tokens that go to zero when the reader asks for reduced motion The same tokens in your own transitions

Where to change something

Pick the mechanism by how far the change should reach. The demo applies each one to the same card and shows the code that does it.

You want to change Use Example
The whole look: color, type, shape and shadow together A theme <html data-theme="classic">
The brand color everywhere An accent, or the hue seed <html data-accent="forest"> or :root { --hue-primary: 150; }
Light or dark data-mode <html data-mode="dark">
The typeface A font token :root { --font-heading: var(--font-serif); }
Spacing everywhere The spacing unit or a density <body data-layout-density="compact">
Corners or shadows everywhere The radius or shadow tokens :root { --radius-m: 0px; }
Any of the above in one region The same attribute or token on that element <aside data-mode="dark">
Every instance of one component The component's own token, where it has one button { --btn-color: oklch(45% 0.14 150); }
One element, to a look the library already has A class variant or a data-* attribute <button class="ghost">
One element, to a look it does not have Plain CSS, written outside any layer .price { font-size: var(--font-size-xl); }

Start at the top of the table. A change made with a theme or a token keeps working when the theme, the mode or the density changes. A change made with a fixed value in your own rule does not.

How a token change reaches an element

Tokens are inherited custom properties, so a value set on an element applies to everything inside it. One rule decides how far a change spreads: a token that is computed from another token is computed on the element that declares it.

Most tokens are declared on :root. --color-interactive, for example, is declared there as var(--color-primary). Set --color-primary on :root and links and buttons follow, because both tokens are on the same element. Set it on a <section> and rules that read --color-primary follow, but --color-interactive still holds the page's value.

The library re-declares its derived tokens on any element that has data-theme, data-mode or data-accent. So to recolor a region, use one of those attributes and not a bare custom property:

Tokens that hold a plain value, such as --radius-m, --shadow-s and --font-sans, need none of this. Set them on any element.

Cascade layers

The library declares its layers once, in this order. Later layers win over earlier ones.

Layer Holds
tokensCustom properties with their default values
resetBrowser normalization and the hidden rules
native-elementsHTML elements and their class variants
custom-elementsLayout elements and other lightweight custom elements
web-componentsComponents with script
utilsAttribute helpers such as density, surfaces, shapes and print rules
bundle-themeThemes and accents
bundle-effectsOpt-in effects such as data-shadow
bundle-componentsComponent styles from packs

Your stylesheet sits above all of them when its rules are outside a layer. Overrides explains the details and the two exceptions.

What holds it in place

These checks run on every change to the library.

Check What it catches
Token references A var() in the library, a demo or a documentation page that names a token nothing defines
Element classes A class in the element layer that no demo, documentation page or module uses
Layer placement A theme file with rules outside the theme layer, or a token file with a rule that sets more than custom properties
Contrast tests Text and control colors below AA, measured in a browser under each bundled theme in light and dark

In this section

Color

Semantic color tokens, the brand seeds, light and dark, and status colors.

Typography

The type scale, wrapping, emphasis, headings and long-form prose.

Typefaces

System font stacks, the font slots, your own fonts and the font packs.

Borders and Shape

Border widths, the radius scale and the opt-in shape attributes.

Shadows

The elevation scale and the data-shadow effects.

Surfaces

Background tokens for each level, and translucent and paper surface types.

Overrides

Four ways to change a default, and why your CSS wins without !important.

Spacing is covered with the layouts that use it: see Spacing and Density and Content Width. Two reference sections sit beside these guides: Themes lists every theme and shows how to write one, and Tokens lists every token and its value.

↑