Shadows
Use shared elevation and shadow tokens to distinguish overlapping elements
Use a shadow when it helps distinguish an element from the content behind it. Keep the default elevation of a library component, and use semantic elevation tokens when building related custom elements.
elevation.raise.macroResolves to mdA clearer separation where surfaces overlap.
Change the elevation and switch between micro and macro to compare the live tokens. The lifted drawing makes the relationship visible; a shadow token itself does not move or resize an element.
Semantic elevation
The preset defines four elevation names, each with a micro and macro variant. Micro uses a smaller shadow; macro uses a larger one. Choose between them based on the element's size and context.
| Elevation | Micro resolves to | Macro resolves to |
|---|---|---|
elevation.drop | 2xs | xs |
elevation.lift | xs | sm |
elevation.raise | sm | md |
elevation.float | md | lg |
Use the complete name, such as elevation.raise.macro, with boxShadow:
import { css } from "@hashintel/ds-helpers/css";
export const floatingPanel = css({
backgroundColor: "bgSolid.surface",
borderWidth: "1px",
borderColor: "bd.subtle",
borderRadius: "lg",
boxShadow: "elevation.raise.macro",
});Shadows in context
Think about what overlaps, how large it is, and how close it should feel to the content beneath it. These are illustrative compositions, not overrides for the library components' default styles.
A compact menu needs enough separation to read as a layer above its context.
elevation.raise.microA floating toolbar sits above the canvas without turning into the main event.
elevation.float.microA broader shadow gives an overlapping panel a clear relationship to what is behind it.
elevation.float.macroHow a shadow is built
Many base shadows combine two layers: a tight contact shadow and a softer ambient shadow. Here is md taken apart. Both layers use black at 10% opacity; their offsets, blur, and spread differ.
0 2px 4px -2pxThe tighter shadow holds the surface close to its ground.
0 4px 6px -1pxThe softer shadow spreads the separation over a wider area.
shadows.mdCombined, the two layers make the surface feel grounded.
In a box-shadow value, the first two lengths set the horizontal and vertical offset, followed by blur and spread. A negative spread pulls the shadow inward before blurring, keeping a larger shadow from becoming too heavy.
Base shadows
Base tokens remain available for cases where the semantic scale does not express the required treatment. Each tile below uses the same surface size so you can compare the shadows directly.
shadows.2xsshadows.xsshadows.smshadows.mdshadows.lgshadows.xlshadows.2xl| Family | Available values |
|---|---|
| Outer shadows | 2xs, xs, sm, md, lg, xl, 2xl. |
| Inset shadows | inset-2xs, inset-xs, inset-sm. |
Use boxShadow: "sm" in a Panda style object, or token.var("shadows.sm") when reading the CSS variable through the token helper. Inspect the token playground for the full shadow definitions.
Inset shadows
An inset shadow sits inside a surface. Use it sparingly to suggest a recessed area, such as a custom input well. It should not replace a visible control boundary or a focus indicator.
shadows.inset-2xsshadows.inset-xsshadows.inset-smAcross backgrounds
An opaque background keeps underlying content from showing through. A border can preserve the panel's edge when its shadow is hard to see, especially in dark mode.
Turn the edge off to see how much separation it contributes. In dark mode, prefer a clear surface and a restrained border over a stronger, darker shadow. The examples below keep the shadow identical.
A shadow reads clearly against a pale ground.
A lighter surface and a quiet edge do more of the work.
An opaque panel keeps the color underneath from bleeding through.
All three use elevation.float.macro. Only the background, surface, and edge change.
Composition
- Start with the lowest elevation that separates the element from its surroundings.
- Use spacing and borders to group content within a page. Reserve stronger shadows for meaningful overlap.
- Avoid adding a second shadow around a component that already supplies one.
- Check the result on light, dark, and colored backgrounds, including where two floating elements overlap.
An overflow rule cuts the shadow off at the edge.
Allow space around elevated surfaces and use the overlay's positioning system.
A shadow changes appearance; it does not change stacking order. Keep overlay positioning, clipping, and focus behavior in the overlay component. Prefer Dialog, Popover, or Menu to a custom floating container for those interactions.
See Motion when an elevated element enters or leaves the screen.
Last updated on 2026-10-31
Was this page helpful?