Skip to content
Okaapiأوكابي
Framework for the code
Theme
Okaapi on GitHub

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.

TokenValueTailwindFor
--ui-layer-below-1z-belowBehind the content of its own box: a decorative background or pattern.
--ui-layer-base0z-baseThe page itself. Also resets a z-index set somewhere else.
--ui-layer-raised1z-raisedInside one component, over its siblings: a table's sticky header.
--ui-layer-cover2z-coverInside one component, over everything in it: a table's loading cover.
--ui-layer-sticky100z-stickyBars that stick while the page scrolls: a sticky page header, a side bar.
--ui-layer-fixed200z-fixedBars fixed to the screen: an app bar, a bottom navigation, a floating action button.
--ui-layer-dialog1000z-dialogDialogs, alert dialogs, drawers and bottom sheets, with their backdrop.
--ui-layer-popover1100z-popoverSelect and combobox lists, menus, popovers: they open from inside a dialog.
--ui-layer-tooltip1200z-tooltipTooltips: they label controls inside popovers and menus.
--ui-layer-toast1300z-toastToasts: on top of every overlay, so a note sent from a dialog is seen.
--ui-layer-skip-link1400z-skip-linkThe "Skip to content" link: when focused, nothing may cover it.
Angular
<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.

--ui-layer-sticky · 100

Your element in the stack

Bars that stick while the page scrolls: a sticky page header, a side bar.

Angular
<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.