z-Index

Manages the stacking order of UI elements with consistent rules. Designed so layers like Dropdown, Modal, and Tooltip never conflict.

z-Index Scale

Composed of two categories: base numeric values and semantic tokens.

Base Values (0–50)

0
z-0
10
z-10
20
z-20
30
z-30
40
z-40
50
z-50

Semantic Values

z-sticky100

Sticky header, fixed elements

z-dropdown1000

Dropdown menu, select

z-overlay1100

Overlay, backdrop

z-modal2000

Modal dialog

z-popover2100

Popover, hover card

z-tooltip2200

Tooltip

z-toast3000

Toast notification (topmost)

Interactive Demo

Click each element to see how z-index controls the stacking order.

Base Content
z-index: 0
Dropdown
z-1000
Modal Dialog
z-index: 2000

Appears in front of the dropdown

Tooltip
z-2200

Recommended Values

Recommended z-index tokens for each UI component

Header (sticky)

z-sticky
100

Dropdown Menu

z-dropdown
1000

Select Options

z-dropdown
1000

Backdrop/Overlay

z-overlay
1100

Modal/Dialog

z-modal
2000

Popover

z-popover
2100

Tooltip

z-tooltip
2200

Toast/Notification

z-toast
3000

Layer Hierarchy

Higher z-index values appear in front.

BaseRegular content
z-0-50
StickyFixed header
z-100
DropdownMenu
z-1000
OverlayBackground mask
z-1100
ModalDialog
z-2000
PopoverPopup card
z-2100
TooltipHover hint
z-2200
ToastNotification
z-3000
Higher up = higher z-index value = appears in front

Common Issues

Common z-index issues and how to resolve them

Modal is hidden behind a dropdown

The dropdown is creating a new stacking context

Use a Portal to render the modal directly under body

Element doesn't come to front even with z-index: 9999

The element is constrained by the parent's stacking context

Check the parent's z-index, or use isolation: isolate

position: fixed element is behind the modal

Fixed elements still need an appropriate z-index

Use a z-index higher than z-modal (e.g. z-toast)

Stacking Context

What is a Stacking Context?

z-index comparisons only apply within the same stacking context. A new stacking context is created when:

  • An element has position: absolute/relative/fixed and a z-index set
  • An element has opacity less than 1
  • An element has transform, filter, or perspective applied
  • An element has isolation: isolate set

Best Practices

Do

  • Use semantic tokens (e.g. z-modal) instead of arbitrary values
  • Use a Portal to render modals directly under body
  • Use isolation: isolate to explicitly control stacking contexts
  • Plan your z-index layer hierarchy up front

Don't

  • Arbitrary large values like z-index: 9999
  • Bumping z-index every time something breaks
  • Implementing without considering stacking context
  • Abusing hardcoded z-index values