The z-index determines the stacking order of elements.
The z-index determines the stacking order of elements, dictating which elements appear in front of or behind others when they overlap. Elements with higher z-index values are displayed on top of those with lower values. Different UI components can share the same elevation style, such as shadows or visual depth cues, to maintain a consistent look and feel. However, each UI component should be assigned a different z-index value to accurately represent their relative stacking order within the interface.
Level | Size | Z-index | Usage | Example |
|---|---|---|---|---|
Medium | lg | 500 | Overflow menu/Dropdown menu | |
800 | Navigation bar | |||
High | xl | 1100 | Floating button | |
1300 | Drawer | |||
1500 | Dialog | |||
1600 | Feedback message (Alert, Message, Banner, Toast) | |||
2xl | 1800 | Popover | ||
2000 | Tooltip |