Semantic Tokens

Semantic tokens are purpose-based design tokens that reference primitive colors. They describe where a color is used, not what it is.

Dark mode is supported as of v0.4.1: semantic tokens remap automatically when dark mode is active (see Dark mode below).

Why Semantic Tokens?

LayerExamplePurpose
Primitive--color-primary-500The raw color value
Semantic--background-primaryWhere that color is used

This separation enables:

  • Theming — Change --background-page in dark mode without touching primitives
  • Consistency — Components use purpose-based tokens, not arbitrary colors
  • Maintainability — Update one semantic token, all usages update

Token Categories

Backgrounds

PreviewTokenLight valueDark valuePurpose
--background-defaultwhiteneutral-900Primary content area
--background-pageneutral-50#0f0e0dPage background
--background-mutedneutral-100neutral-700Muted surfaces
--background-subtleneutral-200neutral-500Subtle surfaces
--background-elevatedwhiteneutral-700Modals, dropdowns
--background-overlayrgba(28,25,23,0.5)rgba(0,0,0,0.7)Backdrop behind modals
--background-primaryprimary-500primary-500Primary actions
--background-primary-subtleprimary-100color-mix primarySubtle primary tint
--background-successgreen-50color-mix greenSuccess states
--background-warningamber-50color-mix amberWarning states
--background-errorred-50color-mix redError states
--background-infoblue-50color-mix blueInfo states
--background-navprimary-100neutral-700Sidebar/nav background
--background-nav-hoverprimary-200neutral-500Nav item hover
--background-nav-activeprimary-500primary-500Nav item active

Foregrounds

PreviewTokenLight valueDark valuePurpose
--foreground-defaultneutral-900neutral-100Primary text
--foreground-mutedneutral-500neutral-400Secondary text
--foreground-subtleneutral-400neutral-500Tertiary text
--foreground-primaryprimary-700primary-200Primary accent text
--foreground-successgreen-700green-200Success text
--foreground-warningamber-700amber-200Warning text
--foreground-errorred-700red-200Error text
--foreground-infoblue-700blue-200Info text
--foreground-on-primarywhitewhiteText on primary backgrounds
--foreground-navneutral-700neutral-300Nav item text
--foreground-nav-hoverneutral-900neutral-100Nav item hover text
--foreground-nav-activewhitewhiteNav item active text

Borders

PreviewTokenLight valueDark valuePurpose
--border-defaultneutral-200neutral-500Default borders
--border-mutedneutral-100neutral-600Subtle borders
--border-strongneutral-300neutral-400Emphasized borders
--border-primaryprimary-500primary-500Primary accent borders
--border-errorerrorerrorError state borders
--border-successgreen-200color-mix greenSuccess state borders
--border-warningamber-200color-mix amberWarning state borders
--border-infoblue-200color-mix blueInfo state borders
--border-error-subtlered-200color-mix redSubtle error borders

Dark mode

In dark mode, semantic tokens resolve to different primitives (or color-mix tints) while primitive tokens stay the same. --background-default might map to white in light mode and neutral-900 in dark mode; components that use semantic variables pick up the correct surfaces and text without code changes.

Dark mode is activated when:

  1. The prefers-color-scheme: dark media query matches and the root is not forced to light, or
  2. The .dark class is on <html> (this overrides the system preference), or
  3. .light on <html> forces light mode even when the system prefers dark.

For a manual toggle and localStorage pattern, see Q4.3 in the Integration Guide.

Use the semanticDark export from @akanaka-design/tokens when you need resolved dark hex values in TypeScript.

Swatches

Click any card to copy the CSS variable name—the same interactive previews as on the Tokens page.

Backgrounds

Foregrounds

Borders

Usage

CSS Variables

.sidebar {
  background: var(--background-nav);
  border-right: 1px solid var(--border-default);
}

.sidebar-link {
  color: var(--foreground-nav);
}

.sidebar-link:hover {
  background: var(--background-nav-hover);
  color: var(--foreground-nav-hover);
}

.sidebar-link.active {
  background: var(--background-nav-active);
  color: var(--foreground-nav-active);
}

Tailwind Utilities

Semantic tokens are available as Tailwind utilities:

<aside className="bg-background-nav border-r border-border">
  <a className="text-foreground-nav hover:bg-background-nav-hover hover:text-foreground-nav-hover">
    Dashboard
  </a>
</aside>

TypeScript

import { semantic, cssVars } from "@akanaka-design/tokens";

// Raw hex values
const navBg = semantic.background.nav; // "#FADDD5"

// CSS variable references
const navBgVar = cssVars.semantic.background.nav; // "var(--background-nav)"

For dark mode hex values, import semanticDark alongside semantic.