Skip to main content
PimentCSS v1.0.1, what's new
Home

Depth & shadows

Elevation shadows and z-index tokens for cards, overlays, and modals.

Overview

OKLCH elevation tokens map to utilities (.shadow-xs.shadow-xl, .shadow-inset) and to components (cards, menus, snackbars). Sources and overrides:

LayerSourceUtilities
Tokenstokens/depth.css--shadow-xs--shadow-xl, --shadow-inset
Sass defaultsscss/abstracts/_variables.scss$shadow-sm, $shadow-md, …
Classesscss/utilities/_shadow.scss.shadow-*, .shadow-none
ComponentsCard, dropdown, snackbar, …Built-in box-shadow: var(--shadow-*)

Prerequisites

  • PimentCSS installed, Installation (shadow utilities ship in the default bundle).
  • Semantic surfaces, readable panels from Colors (--surface-elevated, borders).
  • Stacking, combine shadows with z-index on overlays (dropdowns use z-index: 100 in component SCSS).

Canonical tokens

Edit tokens/depth.css for OKLCH shadow stacks. Dark mode overrides live under [data-theme="dark"] and prefers-color-scheme: dark.

Elevation scale

All levels share one stage so you can compare blur and spread. LG and XL use a second shadow layer (XL is wider and stronger). In dark mode, tiles sit on the same muted preview surface as the layered demo below so black shadows stay visible.

XS
SM
MD
LG
XL
StepTokenClassTypical use
XS--shadow-xs.shadow-xsChips, subtle lift on controls
SM--shadow-sm.shadow-sm.card--elevated, snackbar
MD--shadow-md.shadow-mdDropdown, autocomplete panel
LG--shadow-lg.shadow-lgSticky bars, popovers
XL--shadow-xl.shadow-xlModals, highest overlay

Preview is documentation-only (.pdoc-depth-*). In your app, apply .shadow-* on real surfaces.

Inset shadow

Recessed surfaces (wells, pressed tracks). Utility: .shadow-inset · token --shadow-inset.

Layered UI

Stack surfaces in order: page, elevated card, then dialog overlay. Increase shadow with each layer; manage focus and use role="dialog" + aria-modal="true" on the top layer.

Page · --surface-page
Card · .shadow-sm
Overlay · .shadow-xl

Components using shadows

Prefer component classes before ad-hoc utilities so elevation stays aligned with the design system. .card--elevated sets outer padding to 0: wrap content in .card__body (or header/footer) so spacing comes from the card API. For custom panels, use spacing utilities (.p-3, .gap-2, see Layout).

ComponentShadow tokenNotes
.card--elevated--shadow-smDefault raised card
.snackbar--shadow-smFloating feedback
.dropdown__panel--shadow-mdMenus, z-index: 100
.autocomplete__panel--shadow-mdSuggestions panel
.theme-toggle--shadow-xsCompact control chrome

Card

Uses --shadow-sm via .card--elevated and .card__body padding.

Account

Utility classes

Apply on any element. Use .shadow-none to clear shadows when switching variants.

ClassCSS variable
.shadow-inset--shadow-inset
.shadow-xs--shadow-xs
.shadow-sm--shadow-sm
.shadow-md--shadow-md
.shadow-lg--shadow-lg
.shadow-xl--shadow-xl
.shadow-nonenone

Customize (Sass)

  1. Override shadow stacks

    Pass !default variables when importing PimentCSS. Keep OKLCH alpha low enough for AA contrast on adjacent text.
    @use "pimentcss-design-system" with (
      $shadow-sm: 0 4px 12px oklch(40% 0.04 262 / 0.18),
      $shadow-md: 0 12px 24px oklch(40% 0.04 262 / 0.2),
    );
  2. Rebuild CSS

    Regenerate dist/pimentcss.min.css after token edits.
    npm run build:css

See Customization for partial imports (pimentcss-design-system/core includes depth tokens).

Accessibility (RGAA / WCAG)

Depth without barriers

  • Do not rely on shadow alone to convey state or errors (RGAA 10.7). Add text, icons, or aria-* attributes.
  • Focus visible, overlays must not trap keyboard users; restore focus on close. Ring: --focus-ring (3px).
  • Contrast on surfaces, elevated panels still need --text-body on --surface-elevated ≥ 4.5:1 (see Colors).
  • Reduced motion, avoid animating box-shadow for large transitions; use opacity or border when prefers-reduced-motion: reduce.
  • Dark mode: re-check cards and menus after switching theme; dark stacks use higher-alpha blacks in tokens/depth.css.

Next steps