Z-index decides which element is drawn on top when two overlap. Beehexa uses seven named layers instead of free numbers, so a menu never opens behind a dialog and a toast never hides under the scrim.
autosticky100Sticky table headermodal400Dialog, drawer, scrimspotlight500Product tourtooltip600Tooltiptoast700Toast, skip linkHow it works
- A higher layer covers a lower one. Values run from 100 to 700 in steps of 100, leaving room for a new layer.
- Pick the layer by what the element does, not by how high a number you need.
- A layer only competes with its neighbours. An element with its own z-index, transform, filter or opacity below 1 starts a new stacking context; nothing inside can rise above it. That is why a list inside a dialog is rendered inside the dialog.
Elevation shows how high a surface looks; z-index makes sure it is drawn on top. A menu needs both.
| Layer | Token | Value | Elevation | Use for |
|---|---|---|---|---|
| Sticky | z-index.sticky |
100 | Page | Sticky table headers and toolbars |
| Navigation | z-index.navigation |
200 | Page | App header, side navigation |
| Overlay | z-index.overlay |
300 | Overlay | Menus, select lists, popovers |
| Modal | z-index.modal |
400 | Modal | Dialogs, drawers and their scrim |
| Spotlight | z-index.spotlight |
500 | Modal | Product tour, onboarding spotlight |
| Tooltip | z-index.tooltip |
600 | none | Tooltips |
| Toast | z-index.toast |
700 | Overlay | Toasts, the skip link |
Why this order
- Menus cover the navigation they open from.
- A modal blocks the whole page, menus included.
- A tour can point at something inside a dialog.
- A tooltip explains a control, wherever that control is.
- A toast reports on the whole app, so nothing covers it.
On a screen
- 1
z-index.navigationApp header - 2
z-index.stickyTable header while the table scrolls - 3
z-index.overlayMenu opened from a button - 4
z-index.tooltipTooltip on an icon button - 5
z-index.toastToast
Inside one component, values from 1 to 9 need no token, for example to lift the focused button in a button group.
Do and don’t
Give toasts z-index.toast. A toast stays readable while a dialog is open.
Don’t give a toast a lower value than the dialog. It ends up under the scrim.
Render a list that opens inside a dialog inside the dialog, so it can run past the dialog’s edge.
Don’t let the dialog clip the list. Raising its z-index does not fix that.
Put the scrim before the dialog. Both use z-index.modal, so the dialog draws on top.
Don’t put the scrim after the dialog. It dims the dialog too.
Tokens
| Token | Value | Description |
|---|---|---|
--bh-z-index-sticky | 100 | Sticky table headers and toolbars inside the page. |
--bh-z-index-navigation | 200 | App header and side navigation. |
--bh-z-index-overlay | 300 | Dropdowns, menus, popovers and select lists. |
--bh-z-index-modal | 400 | Dialogs, drawers and their scrim. |
--bh-z-index-spotlight | 500 | Product tour and onboarding spotlight, above a dialog. |
--bh-z-index-tooltip | 600 | Tooltips, above everything you can interact with. |
--bh-z-index-toast | 700 | Toasts and the skip link: always on top. |