Z-index
Z-index utilities control stacking within the same stacking context. Pair them with a positioned element from the Position page when the element needs to leave the normal flow.
Classes
Section titled “Classes”| Class | Value |
|---|---|
z-minus-1 |
-1 |
z-0 |
0 |
z-plus-1 … z-plus-12 |
1 … 12 |
<div class="relative z-plus-2">Sits above its siblings</div>Responsive: z-md-plus-2, z-lg-minus-1, and so on. The base class reads the
--z knob:
These classes are in the separate responsive module: import
nightcss/utilities/responsive after the base bundle, or use
nightcss/full.
<div class="z-plus-2" style="--z: 5">…</div>Named layers
Section titled “Named layers”The numbered scale is for small, local stacking decisions. Named layers are
better for anything structural — use the --nc-z-* tokens:
| Token | Value |
|---|---|
--nc-z-base |
0 |
--nc-z-dropdown |
1000 |
--nc-z-sticky |
1020 |
--nc-z-overlay |
1040 |
--nc-z-modal |
1060 |
--nc-z-toast |
1080 |
.dropdown { z-index: var(--nc-z-dropdown);}Stacking contexts
Section titled “Stacking contexts”A high z-index only wins inside its own stacking context. A positioned element
with a z-index, a transform, a filter, opacity below 1, or
isolation: isolate starts a new context, and children cannot escape it.
- Keep the numbered scale local to a component.
- Use the named tokens for page-level layers: overlay, modal, toast.
- Add
isolation: isolateto a card that contains its own floating badge rather than raising the badge’s number. - Do not use
z-indexto fix a layout that should be a different stacking order in the DOM.
Use in CSS
Section titled “Use in CSS”The class is the markup shorthand. The same style in a component stylesheet:
.dropdown { z-index: var(--nc-z-dropdown);}.badge { z-index: 2;}The Sass subpackage exposes the same value: nc.nc-z("dropdown"). Named layers
have an accessor; numbered values stay literal. See Sass
subpackage.
A breakpoint is the same declaration inside a media query; you do not need a second class.