Skip to content

Nubisco UI uses a two-tier z-index system driven by CSS custom properties. All layers are declared as --nb-zindex-* variables on :root so host applications can shift the entire stack by overriding --nb-zindex-root.

How it works

Every z-index value is a calc() expression relative to a named ancestor, not a hardcoded number. This means:

  • Changing --nb-zindex-root shifts the whole stack — useful when embedding the UI inside an iframe or alongside a third-party shell with its own stacking.
  • Each layer chains off the one below it, so inserting a new layer never requires renumbering the rest.

Root context layers

These are the layers available in the standard page context, in ascending order:

VariableComputed valuePurpose
--nb-zindex-root0Baseline. All others build on this.
--nb-zindex-inspectorroot + 1Element inspector overlays.
--nb-zindex-table-rowsroot + 1Table row z-positioning.
--nb-zindex-table-rows-fixedroot + 2Sticky/fixed table rows.
--nb-zindex-table-rows-last-fixedroot + 3Last sticky row, above the others.
--nb-zindex-tableheaderroot + 5Sticky table header, above all rows.
--nb-zindex-selectroot + 10Select panel.
--nb-zindex-dropdownroot + 10Dropdown panel.
--nb-zindex-pageheaderdropdown + 1Page-level header bar.
--nb-zindex-splitviewhandledropdown + 2Split-view resize handle.
--nb-zindex-debugroot + 15Debug/inspector overlays, above all page content.
--nb-zindex-titlebarroot + 20Application title bar.
--nb-zindex-navigationroot + 100Main navigation (sidebar, top nav).
--nb-zindex-backdropnavigation + 200Modal backdrop scrim.
--nb-zindex-modalbackdrop + 1Modal dialog.
--nb-zindex-toastmodal + 50Toast / notification. Always above modals.
--nb-zindex-tooltipmodal + 100Tooltip. Topmost layer.

Default values

With --nb-zindex-root: 0 the concrete values are: inspector=1, tableheader=5, select/dropdown=10, pageheader=11, splitviewhandle=12, debug=15, titlebar=20, navigation=100, backdrop=300, modal=301, toast=351, tooltip=401.

Components that open overlays (select panels, dropdowns) use <Teleport> to escape the DOM subtree, which means they cannot inherit a z-index re-scoped on the modal element. To handle this, a separate set of variables is provided for use inside a modal:

VariableComputed valuePurpose
--nb-zindex-modal-selectmodal + 10Select panel opened from within a modal.
--nb-zindex-modal-dropdownmodal + 10Dropdown opened from within a modal.
--nb-zindex-modal-debugmodal + 11Debug overlay within a modal context.

Components that are modal-aware (e.g. NbSelect) should automatically switch to the modal-context variable when rendered inside an NbModal. This is typically handled by a provide/inject flag set by the modal.

Overriding the root

To shift the entire Nubisco stack above a third-party layer:

css
:root {
  --nb-zindex-root: 1000;
}

All other variables recompute automatically via calc().

Adding a new layer

Edit src/styles/variables/_layout.scss and add an entry to $zIndexesRoot (or $zIndexesModal for modal-context overlays). Chain it off the nearest semantic ancestor rather than using an absolute number:

scss
$zIndexesRoot: (
  // ...
  my-overlay: #{calc(var(--nb-zindex-dropdown) + 5)} // ...
) !default;

This generates --nb-zindex-my-overlay on :root automatically.