Single source for the theme's design tokens, CSS usage patterns, and governance rules. Supersedes the legacy token governance/system/usage docs by distilling active guidance that matches the current codebase.
- Token store:
src/design-tokens/tokens.scss(277 tokens after consolidation). - Runtime managers:
CSSVariableWriter,CSSVariableBatcher,SpicetifyColorBridge, and music/color services keep dynamic tokens (--sn-dynamic-*,--sn-oklab-*,--sn-music-*) in sync with visuals. - Build integration: SASS/PostCSS preserves comments and ordering; TypeScript accesses tokens through CSS variables at runtime.
| Category | Prefix Examples | Purpose |
|---|---|---|
| Animation & Transitions | --sn-anim-*, --sn-transition-* |
Durations, easings, breathing effects. |
| Color Palettes | --sn-color-*, --sn-cosmic-* |
Base Catppuccin palette. |
| Dynamic/OKLAB | --sn-dynamic-*, --sn-oklab-*, --sn-musical-oklab-* |
Music/album art driven colors. |
| Layout & Depth | --sn-layout-*, --sn-visual-effects-* |
Spacing, radius, z-index, depth cues. |
| Music Sync | --sn-music-* |
Realtime metrics exposed by MusicSyncService. |
| UI Systems | --sn-ui-*, --sn-sidebar-* |
UI-specific styling knobs. |
- Format:
--sn-{category}-{name}[-{variant}](e.g.--sn-dynamic-accent-rgb). - Categories listed above; keep names semantic and reusable.
- Addition checklist:
- Search existing tokens (
rg "--sn-" src/design-tokens/tokens.scss). - Confirm reuse in 2+ places or runtime dependency.
- Document purpose, planned usage, and TypeScript interactions.
- Follow prefixes and provide example snippet in PR.
- Search existing tokens (
- Review requirements: maintainer approval, duplicate scan (
./scripts/validate-tokens.sh), updatedocs/STYLING_AND_TOKENS.mdif behavior changes. - Deprecation: mark alias with comment, provide migration note, remove only in major release (see legacy migration history below).
@use "../core/_design_tokens" as *;
.card {
background: oklab-color('accent', 0.12);
border-radius: var(--sn-layout-radius-lg);
transition: transform var(--sn-transition-fast-duration) var(--sn-anim-easing-organic);
}- Prefer helpers (
oklab-color, mixins) over rawvar()when available. - Keep var chains <=2 levels; tokens already optimized for delegation.
import { CSSVariableWriter } from "@/core/css/CSSVariableWriter";
CSSVariableWriter.getInstance().setVariables("visual-effects", {
"--sn-dynamic-accent-rgb": palette.accent.rgb,
"--sn-music-beat-pulse-intensity": beatState.intensity.toString(),
});- Use
CSSVariableWriter/CSSVariableBatcherfor batched DOM updates. - Music-driven values come from
MusicSyncService, color harmonization fromColorHarmonyEngine(documented indocs/COLOR_AND_AUDIO.md).
- When touching legacy code, update to the new prefix and document the change in the PR.
- Reference mapping lives in
docs/legacy/tokens/LEGACY_TOKEN_MIGRATION.mdfor historical context.
npm run validate:tokens(orscripts/validate-tokens.sh) checks for duplicate or missing tokens.plans/token-governance/(if present) tracks in-flight proposals-ensure this doc reflects approved changes.- For CI lint/formatting, tokens are treated as regular CSS variables; ensure new tokens do not break minified outputs.
- Reviewed
docs/token-governance.md,token-system-architecture.md,token-usage-guide.md,LEGACY_TOKEN_MIGRATION.md, andsrc/design-tokens/tokens.scsswhile drafting this document.