Skip to content

Shadow

A shadow is an elevation cue, not decoration. Pick the lowest level that separates the surface from what is behind it. If the surface is inline with the page, a border is usually enough.

Token Class Use for
--nc-shadow-xs shadow-xs Inputs, pressed buttons, quiet cards
--nc-shadow-sm shadow-sm Cards, sticky headers
--nc-shadow-md shadow-md Dropdowns, popovers, floating panels
--nc-shadow-lg shadow-lg Modals, hero panels, the top layer

The named ladder is five Material-style levels:

Class Character
shadow-level-1 A tight, quiet edge
shadow-level-2 A lifted card
shadow-level-3 A panel above the page
shadow-level-4 A dialog
shadow-level-5 The topmost layer
<div class="shadow-level-1">1</div>
<div class="shadow-level-3">3</div>
<div class="shadow-level-5">5</div>

Both ladders read the --shadow knob, so one instance can be re-tinted without a new class:

<div class="shadow-lg rounded-xl p-6" style="--shadow: 0 18px 40px color-mix(in oklch, var(--nc-accent) 24%, transparent)">
A floating panel with an accent glow.
</div>

The default shadows are neutral black, which is correct on light surfaces and nearly invisible on dark ones. On dark surfaces, pair the shadow with a border, or add a lighter inner highlight:

.card {
border: 1px solid var(--nc-border);
box-shadow: inset 0 1px 0 color-mix(in oklch, var(--nc-text) 8%, transparent);
}

The inner highlight uses --nc-text, so it is dark on a light page and light on a dark page. The border does the separation; the shadow only adds a subtle edge.

<article class="bg-surface-raised border rounded-lg shadow-sm p-4">
<p class="text-xs spacing-wider text-muted">RAISED</p>
<h3 class="text-xl">Project notes</h3>
<p class="text-sm text-muted">A quiet surface with a border and a small shadow.</p>
</article>

Raised

Project notes

A quiet surface with a border and a small shadow.

ACCENT

Inverted surface

Use text-accent-contrast on an accent background.

The recipe is four decisions:

  1. Background — bg-surface, bg-surface-raised, or bg-accent.
  2. Border — border when the surface needs an edge in dark mode.
  3. Radius — usually rounded-lg for cards.
  4. Shadow — shadow-sm for a card, shadow-md or shadow-lg for something that floats above the page.

Hover lift belongs to the surface; the transition belongs to Motion. Keep it short and animate only transform, box-shadow, and colour:

.card {
transition:
transform var(--nc-duration-fast) var(--nc-ease-standard),
box-shadow var(--nc-duration-fast) var(--nc-ease-standard),
border-color var(--nc-duration-fast) var(--nc-ease-standard);
}
.card:hover {
transform: translateY(-2px);
box-shadow: var(--nc-shadow-md);
border-color: var(--nc-accent);
}

Focus is handled by the base layer: :focus-visible draws a 2px outline with --nc-ring. Do not replace it with a hover style. If you need a ring on a custom control, use ring-accent or the same token:

.control:focus-visible {
outline: none;
box-shadow: 0 0 0 3px var(--nc-ring);
}
  • A shadow on every card. If everything floats, nothing does. Use borders for most cards and reserve shadows for things that really sit above the page.
  • Radius on the parent but not the media. Add overflow-hidden or frame; see Radius.
  • Accent background with text-muted. Use text-accent-contrast; muted text is tuned for the page surface, not the accent.
  • A dark shadow on a dark page. Add a border or use a lighter highlight.
  • A custom class for every card. If the same four utilities repeat, write one .card class in your own CSS. NightCSS intentionally leaves that decision to you.

The class is the markup shorthand. The same style in a component stylesheet:

.card {
box-shadow: var(--nc-shadow-sm);
}
.modal {
box-shadow: var(--nc-shadow-lg);
}

The Sass subpackage exposes the same values: nc.nc-shadow("sm") and nc.nc-shadow("lg"). See Sass subpackage.

A breakpoint is the same declaration inside a media query; you do not need a second class.