Z-Index
Layer stacking system: named tokens for every UI surface from base to tooltip.
Layer stack — hover a layer to inspect
Token reference
| Token | Value | Scale | When to use |
|---|---|---|---|
| --z-below | -1 | Decorative backgrounds; pseudo-element underlay behind a card or hero. | |
| --z-base | 0 | Default document flow. Most content lives here. | |
| --z-raised | 10 | Cards with hover lift, inline badges, floating labels. | |
| --z-dropdown | 1000 | Dropdown menus, combobox popups, date pickers. | |
| --z-sticky | 1020 | Sticky table headers, anchored section nav. | |
| --z-fixed | 1030 | Fixed-position top nav / bottom toolbar. | |
| --z-modal-bg | 1040 | Semi-transparent backdrop behind modal dialogs. | |
| --z-modal | 1050 | Modal dialogs, alert dialogs, confirmation sheets. | |
| --z-popover | 1060 | Popovers, floating panels — sit above modals. | |
| --z-toast | 1100 | Notification toasts, snackbars — always visible. | |
| --z-tooltip | 1200 | Tooltips — highest layer, never obscured. |
Live demo — toggle layers
Click the buttons to add UI surfaces and observe how each layer correctly sits above or below the others according to its token value.
0
0
0
Modal Dialog
--z-modal · 1050
backdrop · 1040
Usage patterns
Common pitfalls
transform creates a context
Applying transform, filter, or will-change to a parent implicitly creates a new stacking context, capping its children's z-index at the parent's level regardless of token value.
opacity < 1 creates a context
An element with opacity less than 1 forms its own stacking context. A semi-transparent modal backdrop can inadvertently trap a tooltip inside it.
isolation: isolate is intentional
Use isolation: isolate on self-contained components to prevent their internal layers from colliding with the global z-index ladder.
Never hardcode numeric z-values
Magic numbers like z-index: 9999 break the contract. Always use the token. If a token is missing, add it to token.css with a comment, then reference it.