Depth

Interfaces have layers. A dropdown sits above the page. A modal sits above the dropdown. A toast sits above everything. If these layers collide, the user loses trust in the interface.

The Stack

Every layer has a fixed position. No z-index wars. No z-[9999].

LayerTokenWhat lives here
Base0Page content, cards, form controls
Navigationz-depth-navigationSidebars, fixed headers
Dropdownz-depth-dropdownSelect menus, dropdown menus, comboboxes
Popoverz-depth-popoverPopovers, hover cards, tooltips
Overlayz-depth-overlayBackground dim behind modals
Modalz-depth-modalDialogs, sheets, command palettes
Toastz-depth-toastNotifications that sit above everything

These are not suggestions. A dropdown at z-depth-modal is a bug. A modal at z-depth-dropdown is invisible behind its own overlay.

Depth Comes With Shadow

Higher layers cast larger shadows. This is how the real world works. A sheet of paper held close to a desk casts a tight shadow. Held high, the shadow spreads.

DepthShadow
Base (cards, inputs)shadow-sm tight, subtle
Dropdown, popovershadow-md visible but grounded
Modal, sheetshadow-lg clearly elevated

The shadow tokens are in @theme. Tailwind’s shadow-sm, shadow-md, shadow-lg read from the system. Change the shadow definition, every component at that depth updates.

Focus Trap

When a modal opens, keyboard focus is trapped inside it. Tab cycles through the modal’s focusable elements. Escape closes it. Focus returns to the element that opened it.

This is not optional. Without focus trap, a keyboard user tabs behind the modal into invisible content. The overlay dims the page visually, but screen readers and keyboards don’t see visual dimming.