Foundations
Elevation
Three shadow tokens that lift controls, bars and popups above the page.
Deft has three elevation levels. Each one is a single box-shadow made of a 1px ring and a soft drop shadow, so an elevated surface needs no border.
Tokens
theme.css maps each --shadow-* token to an --elevation-* variable that holds the full shadow.
| Token | Utility | Value | Use |
|---|---|---|---|
--shadow-raised | shadow-raised | 1px ring and a 0 1px 2px shadow | Parts that sit just above their container: the indicator of the active tab, the Switch thumb, Sidebar.Pill, Avatar with tone="raised". |
--shadow-floating | shadow-floating | 1px ring and a 0 8px 20px shadow | Bars and panels that slide in over the page: Action bar, and Sidebar when it opens as an overlay below the md breakpoint. |
--shadow-popover | shadow-popover | 1px ring and a 0 10px 28px shadow | Popups, dialogs and notifications: Menu, Select, Combobox and Popover popups, Tooltip, Toast, Dialog, Drawer, the Chart tooltip. |
Shadow colors
The ring and the shadow of each level are palette tokens, so they change with the theme and the palette. These are the values of the base palette:
| Palette token | Light | Dark |
|---|---|---|
elevation-raised-ring | #0000000f | #ffffff12 |
elevation-raised-shadow | #0000000a | #00000066 |
elevation-floating-ring | #00000012 | #ffffff14 |
elevation-floating-shadow | #00000014 | #00000080 |
elevation-popover-ring | #00000014 | #ffffff14 |
elevation-popover-shadow | #00000017 | #00000080 |
In the light theme the ring is a faint dark line. In the dark theme it turns into a faint light line and the drop shadow is much stronger. See Theming for palettes and Colors for the other tokens.
Rules
- Use
bg-overlayundershadow-floatingandshadow-popover. Every popup, Dialog, Drawer, Toast and Action bar pairs the two. The overlay Sidebar is the exception: it keeps itsbg-insettone. - Do not add a border to an elevated surface. The ring inside the shadow is its hairline.
- Keep content flat. Panel, List, Callout and Metric card have no shadow: they are set apart by a background tone or a
border-subtleline. - Pick the radius by the surface, not by the shadow:
rounded-mdfor Tooltip,rounded-lgfor popups and Toast,rounded-xlfor Dialog,rounded-fullfor Action bar. See Radius. - You rarely write these utilities yourself, because the overlay components already carry them. The dashboard does it once, for its bar of unsaved changes, with the same recipe as Action bar:
<div className="sticky bottom-5 z-30 rounded-full bg-overlay shadow-floating">{children}</div>Stacking order
Elevation does not set z-index. The components do:
| Layer | z-index |
|---|---|
| Action bar | 30 |
| Backdrop of the overlay Sidebar | 40 |
| Menu, Select, Combobox, Popover, Tooltip, Dialog, Drawer, overlay Sidebar | 50 |
| Toast | 60 |
A toast therefore stays visible above an open dialog, and a popup opened from an action bar covers it.