Star on GitHub

Elevation

Elevation says how far a surface sits above the page. Orvain UI uses 4 shadow levels, an edge colour that keeps raised surfaces visible in dark mode, and one order for layers to stack in. Every value below comes from @orvain/tokens 0.1.4, the same package the React and Vue components read.

Shadow levels#

Each level has a light and a dark value. In dark mode the shadows are deeper, because a dark ground swallows a soft one.

light

--orvain-shadow-light
light shadow in light and dark mode

Resting surfaces that sit on the page. Cards, feed items, icon tiles, calendar cells.

soft

--orvain-shadow-soft
soft shadow in light and dark mode

A control raised a step off its surface. Toggles, handles, a selected segment.

default

--orvain-shadow-default
default shadow in light and dark mode

Panels that float over the page. Popovers, menus, dropdowns, dialogs.

hover

--orvain-shadow-hover
hover shadow in light and dark mode

A surface lifted under the pointer. Card hover, a floating navbar.

Choosing a level#

Pick the level for what the surface does, not for how strong you want it to look. A surface that moves between states moves between levels: a card rests on light and lifts to hover under the pointer.

LevelUse it forExamples
light
Resting surfaces that sit on the page
Cards, feed items, icon tiles, calendar cells
soft
A control raised a step off its surface
Toggles, handles, a selected segment
default
Panels that float over the page
Popovers, menus, dropdowns, dialogs
hover
A surface lifted under the pointer
Card hover, a floating navbar
Keep shadows light. One level per surface is enough: a card inside a card does not get a second shadow, it gets a border or a change of surface colour.

Edges in dark mode#

On a dark ground a shadow alone hardly separates a surface from the page. So raised surfaces also carry the edge colour: clear in light mode and a faint white hairline in dark. These are the elevation colours the components use:

TokenLightDarkWhat it is for
edge
The hairline around a raised surface. Clear in light mode, 8% white in dark, where a shadow alone barely shows.
shadow
The ink most component shadows are drawn in.
shadow-black
A pure black ink for the deepest drops (dropdown fields, switch cards).
highlight
The inner top highlight on skeuomorphic controls and icon tiles.

The package also has 7 drop colours (drop-ink-static, drop-slate3, drop-navy3, drop-navy6, shadow-slate, shadow-grey, glass). They are the building blocks of individual component shadows, and you will rarely need them directly.

Layer order#

Anything that floats needs a place in the stack. Use these steps rather than a number of your own, so a tooltip always lands above a dialog and a toast above both.

tooltip1600
toast1500
popover1400
modal1300
overlay1200
sticky1100
dropdown1000
raised1
base0

Using the tokens#

Shadows and colours work as they are in CSS. In JavaScript, use the exports for canvas or chart code where custom properties don't reach. The CSS layer is the one that switches with the theme.

Raised card
.card {
box-shadow: var(--orvain-shadow-light), 0 0 0 1px var(--orvain-color-elevation-edge);
transition: box-shadow var(--orvain-motion-duration-base) var(--orvain-motion-easing-standard);
}
.card:hover {
box-shadow: var(--orvain-shadow-hover), 0 0 0 1px var(--orvain-color-elevation-edge);
}
.popover {
z-index: var(--orvain-z-index-popover);
box-shadow: var(--orvain-shadow-default);
}

Dark mode follows data-theme="dark" on any ancestor, or data-theme="system" to follow the reader's setting. The custom properties switch on their own. The JS and SCSS values are the light ones.