The background levels a Vanilla Breeze page is built from, the data-surface attribute for translucent and paper surfaces, and the tokens behind the page background and overlays.
Surface levels
A page is a stack of surfaces: the page itself, panels on it, and things that sit above or below a panel. Each level has a color token, and each token has a light and a dark value. Pick the token by the level, and text set in --color-text stays readable on it.
| Token |
Level |
Used by |
--color-background | The page | <body>, and any region with its own data-theme or data-mode |
--color-surface | A panel on the page | <layout-card>, text inputs |
--color-surface-raised | Above a panel | Hover backgrounds in menus and lists, aside.note |
--color-surface-sunken | Set into a panel | The file input drop area, editor and comment wells |
--color-surface-alt | An alternate fill beside a surface | The track of a segmented control |
--color-surface-overlay | Floating over scrolling content | Dialogs, menus, sticky headers |
In the default light theme the page and the panel are both white, and depth comes from shadows and borders. In dark mode each level is a step lighter than the one below it, because a shadow shows little on a dark page.
.fare-summary { background: var(--color-surface); color: var(--color-text);} .fare-summary pre { background: var(--color-surface-sunken);}
Surface types
The data-surface attribute changes how one region paints its background. It works on any element. Four values make the region translucent, and five give it a paper texture.
| Value |
Result |
frosted | The surface color at 75% opacity, a blur of what is behind it, and a faint border |
tinted | The accent color at 10% opacity over a light blur |
ghost | A surface that is almost clear, with a faint outline and no shadow |
transparent | No background and no shadow |
paper | Off-white paper with a fine grain (charcoal in dark mode) |
dots | Paper with a dot grid |
grid | Paper with ruled squares |
lines | Ruled paper with a margin line |
kraft | Brown kraft paper with a fine grain (dark brown in dark mode) |
<header data-surface="frosted"> <h1>Harbour Line</h1></header>
Tuning the translucent types
The translucent types read a small set of tokens. The one to know is --glass-blur: its default is 12px, and a theme or your CSS can change it. The Glassmorphism theme sets 16px.
| Token |
Default |
Affects |
--glass-blur | 12px | The blur behind frosted |
--glass-saturate | 160% | How much frosted boosts the color behind it |
--glass-surface-opacity | 0.75 | The opacity of the frosted fill |
--glass-border-opacity | 0.2 | The opacity of the frosted border |
--glass-tint-opacity | 0.1 | The opacity of the tinted fill |
:root { --glass-blur: 20px;}
Text over a translucent surface is only as readable as what shows through. Check the contrast against the busiest thing that can end up behind it, or keep such surfaces for headers and panels over a plain background.
Paper types and dark mode
Each paper type has a light and a dark version, and follows the mode like any other surface: pale paper with dark text in light mode, dark paper with light text in dark mode. The colors come from five tokens, --surface-paper, --surface-kraft, --surface-dot, --surface-rule and --surface-margin. To keep a sheet pale on a dark page, put data-mode="light" on the same element. It gives the region the light paper and light-mode text and controls.
Kraft is darker than the other papers in light mode, so the surface adjusts two colors for its contents: muted text is derived from the body text color, and links use the primary color with its lightness capped. Both measure above 4.5:1 against the paper in the default theme, and the link cap applies to any theme's primary color.
<aside data-surface="lines" data-mode="light"> <p>Bring the blue folder on Thursday.</p></aside>
Reduced transparency
When the reader has asked the system to reduce transparency, frosted, tinted, ghost and transparent all become a solid --color-surface with no blur. You do not write anything for this. See Preferences and themes.
The page background
<body> paints from its own set of tokens, so a theme or a page can change the page color or add a gradient or an image without a rule on body. The gradient is painted over the image, and both over the color.
| Token |
Default |
--page-bg-color | var(--color-background) |
--page-bg-gradient | none |
--page-bg-image | none |
--page-bg-attachment, --page-bg-size, --page-bg-position, --page-bg-blend | scroll, cover, center, normal |
:root { --page-bg-gradient: linear-gradient( to bottom, var(--tint-primary-10), transparent 40rem );}
To float the header, main content and footer as separate panels over that background, add data-backdrop to <html>. The <html> page lists its values, and data-canvas does the same for a single element.
Overlays
Two more tokens cover what sits over the page.
| Token |
Default |
Used for |
--color-backdrop | Black at 50% opacity | The scrim behind a modal <dialog> |
--backdrop-blur | 2px | The blur of the page behind that scrim |
Anything that floats over scrolling content should use --color-surface-overlay for its background. It equals --color-surface by default. A theme with translucent surfaces sets it to an opaque color, so menus and dialogs stay readable.
Texture tokens
Five tokens hold repeating patterns you can lay over a surface: --texture-noise, --texture-grain, --texture-dots, --texture-grid and --texture-lines. Nothing in the default theme uses them. The dots, grid and lines patterns are drawn in currentColor. Paint one on a pseudo-element so its opacity does not affect the content.
.poster { position: relative;} .poster::before { content: ""; position: absolute; inset: 0; background: var(--texture-grain); opacity: var(--surface-texture-opacity); pointer-events: none;}
--surface-texture-opacity is 0.05 by default.