Token Naming
Consistent token naming lets human authors, AI agents, WCAG contrast linters, and CSS code generators interpret your DESIGN.md without guesswork.
Name by role, not by appearance
Prefer semantic roles over raw appearance descriptions:
| Avoid | Prefer | Why |
|---|---|---|
dark-blue | primary | Survives rebrands without renaming every component reference |
light-gray-box | surface | Communicates hierarchy and activates automated background pairing |
charcoal | text, text-muted | Signals foreground usage to readers and contrast linters |
title-16-bold | label-md | Scales cleanly when responsive sizes change |
If you document raw palette scales (indigo-600, zinc-900), keep your UI components referencing semantic aliases ({colors.primary}, {colors.text}).
Naming patterns for WCAG contrast checks
DesignMD Pro’s Validator automatically pairs foreground and background colors based on token key names (and component property names):
- Foreground keys matching
text,foreground,fg,heading,body,link,label, ortitle(as whole words or dot/underscore/hyphen segments, e.g.text-muted,fg-subtle,body) - Background keys matching
background,bg,surface,card,canvas,page, orfill(e.g.background,surface,card-bg)
Every foreground key is checked against every top-level background key. Keep dark-mode colors nested inside colors.dark.* rather than placing surface-dark next to text-dark in the flat colors map — otherwise light text will be cross-paired against light backgrounds and trigger false low-contrast warnings.
Naming for shadcn/ui and Tailwind exports
When exporting to CSS via the shadcn Theme Generator, standard semantic names (background, surface, primary, on-primary, secondary, muted, accent, destructive, border, ring, text) map automatically to --background, --card, --primary, --primary-foreground, --secondary, --muted, --accent, --destructive, --border, --ring, and --foreground. See Tailwind CSS & shadcn/ui for the full mapping table.
Typography, radius, and spacing scales
Use predictable t-shirt or role-based suffixes:
- Typography:
headline-display,headline-section,title-card,body-md,body-sm,label-md,code-sm - Rounded:
sm,md,lg,xl,full(mdmaps directly to--radiusin shadcn exports) - Spacing:
xs,sm,md,lg,xl(or numeric step names such as1,2,4,6,8)
Component state naming
Keep interactive states as flat sibling entries using -{state} suffixes:
button-primarybutton-primary-hoverbutton-primary-activebutton-primary-disabled
Avoid key collisions and orphaned tokens
@google/design.md lint flags two common naming mistakes:
- Flat/grouped key collisions: defining both
colors.surface: "#fff"and a nestedcolors.surface.elevated: "#fafafa"in the same tree. Usecolors.surface+colors.surface-elevatedor nest all surface variants (colors.surface.base,colors.surface.elevated). - Orphaned tokens: defining tokens that are neither referenced by
componentsnor mentioned in prose (orphaned-tokenswarning). Remove unused keys or document their role under## Colors.
Next steps
- Format: Design Tokens — full token group schema
- Format: Components — sibling state patterns
- Validator & Lint Rules — inspect the exact contrast pairing regexes