Surfaces

Eight surface levels that nest. Components read their substrate from context and lift relative to it, so popovers, dropdowns, and dialogs stay visible at any depth — in both and mode.

Installation

Installs the Elevated primitive plus the surface-context and surface-classes libs — the elevation ladder as code.

The problem

In light mode, we use shadow behind white surfaces to signify elevation. In dark mode, we use progressively lighter backgrounds instead.

But traditional components have a fixed background — a dropdown often ends up the same color as the dialog it sits in. That makes your interface look like this:

Inspect
M
Invite to your workspace
Select role
Workspace ownerCan change workspace settings and invite new members
MemberCan't change workspace settings or invite new members
Restricted memberCan only see and edit content they created
Page background#171717
Dialog#333333
Role dropdown#333333

The solution

Three pieces: tokens, substrate context, and the primitive.

Tokens

Eight bg/shadow pairs. Light mode flattens to white after step 2 (shadow alone carries elevation). Dark mode keeps adding white-opacity plus a layered shadow recipe.

Inspect
Dark
Light

Substrate

Each container knows its own level and tells whatever opens inside. A popover on the page and the same popover inside a dialog both end up at the right depth, without anything passed between them.

Inspect
On the page
Favorites
Recents
Private
BG#171717
Menu#252525
Hover+6%
Selected+10%
Inside a popover
Favorites
Recents
Private
BG#252525
Menu#333333
Hover+6%
Selected+10%
Inside a dialog
Favorites
Recents
Private
BG#333333
Menu#414141
Hover+6%
Selected+10%

Elevated

Wrap a panel and the background settles at the level it belongs to. The shadow doesn't change, so a popover still reads as a popover three layers down.

Inspect
Page
Card
Popover
Menu

Move through levels

Drag both knobs to choose which slice of the ladder to nest. Each layer lifts a single step off the one it sits in — whether you span two levels or all eight.

Inspect
surface-1
surface-2
surface-3
surface-4
14

Examples

Invite dialog

Dialog at surface 5, role picker at surface 7 — no props passed between them.

Inspect
M
Invite to your workspace
Select role
Workspace ownerCan change workspace settings and invite new members
MemberCan't change workspace settings or invite new members
Restricted memberCan only see and edit content they created

Color picker

The format dropdown sits one level above the picker panel.

Inspect
#