Shadows
How depth works in Vanilla Breeze: an elevation scale of shadow tokens, when to use box-shadow and when drop-shadow, and the opt-in data-shadow effects.
The elevation scale
Shadows are tokens. Six levels run from a hairline of depth to a floating panel, and every element that casts a shadow reads one of them. A <layout-card> uses --shadow-s, for example, and --shadow-m with data-variant="elevated".
| Token | Use |
--shadow-xs, --shadow-s, --shadow-m, --shadow-l, --shadow-xl, --shadow-2xl | The elevation scale, lowest to highest |
--shadow-inner | An inset shadow for wells and pressed states |
--shadow-flush | A 1px edge plus a soft drop, as an alternative to a border on a raised surface. See Feel. |
--shadow-none | An explicit reset to no shadow |
.departure-board { box-shadow: var(--shadow-m);} .departure-board:hover { box-shadow: var(--shadow-l);}
The lower three levels are one or two tight layers. From --shadow-l up, each token stacks several layers, a close one for contact and wider, softer ones for ambient light, so a raised surface does not look like one flat blur.
--shadow-xs: 0 1px 2px 0 oklch(0 0 0 / 0.05);--shadow-xl: 0 1px 2px 0 oklch(0 0 0 / 0.05), 0 5px 10px -3px oklch(0 0 0 / 0.06), 0 12px 22px -5px oklch(0 0 0 / 0.08), 0 22px 36px -8px oklch(0 0 0 / 0.1);
Themes and dark mode
A theme can replace the scale. Swiss removes shadows, and themes such as Brutalist and Neumorphism define their own style of shadow under the same token names. In dark mode the library replaces the whole scale, --shadow-xs to --shadow-2xl, and --shadow-inner with stronger values, because a faint shadow does not show on a dark page. --shadow-flush changes its 1px edge from dark to light for the same reason.
To change the scale yourself, set the tokens on :root or on one region:
.timetable { --shadow-s: none; --shadow-m: none;}
box-shadow or drop-shadow
The two look alike and paint differently. Using the wrong one is why a shadow on a clipped badge or a transparent logo comes out as a rectangle.
| box-shadow | filter: drop-shadow() |
| Paints | The element's box: a rectangle, rounded by border-radius | The element's visible pixels, so it follows the real shape |
| Use for | Cards, panels, popovers, raised surfaces | Clipped shapes, transparent PNG and SVG images, text |
| Combines with | Other box shadows, separated by commas | Other filter functions |
| In the library | The --shadow-* tokens, data-shadow="tint", material and glow | data-shadow="shape" |
.badge { clip-path: polygon(50% 0, 100% 100%, 0 100%); box-shadow: 0 4px 6px #0006; } .badge { clip-path: polygon(50% 0, 100% 100%, 0 100%); filter: drop-shadow(0 4px 6px #0006); } .badge { clip-path: polygon(50% 0, 100% 100%, 0 100%); }.badge-shadow { filter: drop-shadow(0 4px 6px #0006); }
A transparent PNG, an SVG or a run of text has its own shape, so drop-shadow goes directly on it. Only clip-path needs the wrapper. The same applies to the shape attributes, which clip.
The data-shadow effects
data-shadow adds a shadow effect to any element. It needs no script. The effects read the theme's tokens, so they change color with the theme, and they sit in the bundle-effects layer, so they replace an element's own shadow.
| Value | Effect |
tint | A colored shadow mixed from --color-accent |
material | Rests at --shadow-m. On hover or keyboard focus it rises to --shadow-xl and moves up 4px. |
shape | A drop-shadow that follows the element's visible shape. On a clipped element, put it on a wrapper. |
glow | A soft halo in the accent color. Add flicker for a slow pulse. |
<article data-shadow="tint">An accent-tinted card</article> <button type="button" data-shadow="material">Lifts on hover</button> <img src="/logo.png" alt="Harbour Line" data-shadow="shape" /> <span data-shadow="shape"><span class="clipped-badge"></span></span> <aside data-shadow="glow flicker">A pulsing halo</aside>
The value is a space-separated list, which is how flicker joins glow. tint, material and glow each set box-shadow, so use one of those three at a time. shape uses filter and can be added to any of them.
Adjusting the glow
The glow reads two custom properties that it sets on the element. Override them in a rule of your own on the same element.
.live-indicator { --shadow-glow-color: var(--color-primary); --shadow-glow-size: 2rem;}
Reduced motion
When the system asks for reduced motion, material still changes its shadow on hover but does not move or animate, and flicker does not run, which leaves the still glow. The data-motion-reduced switch described in Preferences does the same.
On busy backgrounds
tint and glow are about half transparent, so their color survives over a photograph or a texture. If you write a colored shadow of your own, keep it at least that transparent, or the color turns muddy.