Chapter 02 Foundations
Z-index
Layer tokens in a fixed order, so a drawer, a popover in it, a tooltip and a toast can all be open at once.
Layers
Under 100 stays in one component, 100–999 is page bars, 1000 and up is overlays.
| Token | Value | Tailwind | For |
|---|---|---|---|
--ui-layer-below | -1 | z-below | Behind the content of its own box: a decorative background or pattern. |
--ui-layer-base | 0 | z-base | The page itself. Also resets a z-index set somewhere else. |
--ui-layer-raised | 1 | z-raised | Inside one component, over its siblings: a table's sticky header. |
--ui-layer-cover | 2 | z-cover | Inside one component, over everything in it: a table's loading cover. |
--ui-layer-sticky | 100 | z-sticky | Bars that stick while the page scrolls: a sticky page header, a side bar. |
--ui-layer-fixed | 200 | z-fixed | Bars fixed to the screen: an app bar, a bottom navigation, a floating action button. |
--ui-layer-dialog | 1000 | z-dialog | Dialogs, alert dialogs, drawers and bottom sheets, with their backdrop. |
--ui-layer-popover | 1100 | z-popover | Select and combobox lists, menus, popovers: they open from inside a dialog. |
--ui-layer-tooltip | 1200 | z-tooltip | Tooltips: they label controls inside popovers and menus. |
--ui-layer-toast | 1300 | z-toast | Toasts: on top of every overlay, so a note sent from a dialog is seen. |
--ui-layer-skip-link | 1400 | z-skip-link | The "Skip to content" link: when focused, nothing may cover it. |
<div class="fixed z-popover rounded-ui border border-transparent bg-surface p-4 shadow-ui">
Saved
</div>Try a layer
Pick a token for your element and see which layers cover it.
Your element in the stack
Bars that stick while the page scrolls: a sticky page header, a side bar.
<div class="relative z-sticky">…</div>Try them all at once
Drawer, then its popover, its tooltip, then a toast over all.
Rules
- Always a token; never a number between two of them.
- Angular overlays open in the browser's top layer, so the newest one is always on top and z-index does not apply to them.