Skip to content

DOL Figma Semantic Token Naming Convention

activeUpdated

Canonical rule cho naming semantic tokens trong Figma DS files. Decoupled theo usage context - không dùng feature names, không hardcode hex.

DOL DS tokens split theo where they’re applied, không theo color alone. Mỗi category có prefix riêng:

PrefixApplied toExample (role = info)
fill/*Background of frame, shape, auto-layout containerfill/info-dim (subtle tint), fill/info-soft (hover)
text-color/*Text node fillstext-color/info-primary
icon-color/*Icon vector fills - separate from texticon-color/info-primary
border-color/*Stroke fillsborder-color/progress-secondary (focus ring)

Rule: pick prefix by the target property, not by visual result. Icon vector rendered same color as adjacent text → still uses icon-color/*, not text-color/*.

Tokens never reference feature names (no cause-bg, effect-text). Always semantic role:

Domain typeSemantic roleRationale
Descr (description)infoInformational content
CausewarningAttention/alert tone
EffectsuccessPositive outcome

Other domain types map tương tự theo tone. Rule of thumb:

  • Neutral informational → info
  • Cautionary / draws attention → warning
  • Positive / confirmation → success
  • Error / destructive → danger
  • Brand identity → brand (rarely in semantic context; see code UI rules for Brand ≠ Danger)

Suffix sau role name để chọn shade:

ModifierUsage
dimSubtle tint - default background cho tags, pills, quiet states
soft1 notch bolder - hover state, active state background
primaryMain strong shade - text, icons, emphasis elements
secondaryAlternate shade - focus ring stroke, subtle emphasis

Full token name format: {prefix}/{role}-{modifier}.

Examples:

  • fill/info-dim - subtle info background (default)
  • fill/info-soft - info hover background
  • text-color/info-primary - info text content
  • border-color/progress-secondary - global focus ring (progress = active state)
  • Decoupling fill / text / icon / border means a single semantic role can have different shades per usage context (text-primary ≠ bg-dim, both “info”).
  • Feature-name tokens explode when same role applies to new features. Semantic roles are stable across feature evolution.
  • Focus ring uses global border-color/progress-secondary (not type-specific) → keeps focus UX consistent across all interactive elements regardless of component type.
  • Never bind a text-color/* var to a background fill - check prefix matches target property.
  • Icon vectors get icon-color/*, not text-color/* - even if rendered same color as text.
  • When adding UI state (hover/disabled/focus), look for matching intensity modifier before inventing hex. Intensity scale is the design answer.
  • If a needed token doesn’t exist (e.g., hover state for amber role):
    • First: ask user / add to DS-Token
    • Last resort: documented hex fallback
    • Hex is a workaround, not a pattern - don’t repeat.
  • When building from a reference component, extract its boundVariables to learn which semantic tokens it uses - shortest path to DS alignment.

🛑 Match-and-refuse (Figma variant of DIRECTION §10 M&R): nếu bạn sắp bind token kiểu dưới, STOP - don’t normalize the workaround; flag missing token to user/DS team instead. Figma token drift has higher blast radius than code drift (many files inherit).

<dol_anti_pattern scope=“figma-naming-6-binding”>

ID❌ PATTERNVì sao✅ REWRITE
01Hardcoded hex in fills when matching token existsBreaks DS-Token cascade; loses dark-mode + KID-mode variant propagationExtract boundVariables from reference; bind semantic token
02text-color/* applied to icon vectors (prefix mismatch)Semantic category wrong - icons need icon-color/* even if same hex (enables future icon-specific mode variants)Use icon-color/* for icon nodes (§1 4-category rule)
03Feature-named tokens (cause-bg-color, effect-text-color)Couples DS to feature naming; one rename in code breaks token linkage; semantic intent lostUse role: info/warning/success/danger/brand (§2)
04Inconsistent focus ring (per-component color)Focus ring = global accessibility affordance; per-component variation breaks keyboard-nav visual consistencySingle global: border-color/progress-secondary across ALL components
05Inventing new intensity modifier (e.g., “semi-soft”, “extra-dim”)DS team not consulted → token never standardized; becomes orphan referenceStop, ask user/DS team. If genuinely new, flag as DS-extension request; don’t ship inventions

</dol_anti_pattern>

  • Sessional source: ai-memory/lessons/dol-figma-semantic-token-naming.md (historical observation record)
  • Code-side color reference: ../../docs/tailwind-color-guideline.md
  • Design intent: ../ds-guideline/color.md
  • AI entry: ../ai-entry/FIGMA-AI.md