Namespaces & Dot Paths
The rule
Section titled “The rule”A token’s global dot path = $namespace + its nested path inside the file.
tokens/color.json "$namespace": "color" primary.default.value = "#2B4C7C" → full path color.primary.default
tokens/z-index.json "$namespace": "zIndex" modal.value = 1050 → full path zIndex.modalAll cross-file references (ref, a spec’s tokenRefs, a case’s then.tokens) must use the full path.
The three namespace cases
Section titled “The three namespace cases”1. Default: derived from the file name
Section titled “1. Default: derived from the file name”When $namespace is not declared, it is derived from the file name by splitting on - (namespaceFromFileName): the first segment stays as-is, and every other segment is capitalized.
| File name | Derived |
|---|---|
color.json |
color |
z-index.json |
zIndex |
typography.json |
typography |
color-dark.json |
colorDark (derived value, but never actually used) |
Derivation is just a fallback — dark files always declare $namespace explicitly to align with their light counterpart (see below).
2. Explicit declaration
Section titled “2. Explicit declaration”Write $namespace directly:
{ "$namespace": "zIndex", "modal": { "value": 1050 } }A dark file must declare the same $namespace as its light file, otherwise the override keys never land on the same path:
{ "$namespace": "color", "$dark": true, "primary": { "default": { "value": "#3D649E" } } }Only then can the dark override for color.primary.default be merged onto the light token at the same path.
3. Empty string: the top-level keys are the namespaces
Section titled “3. Empty string: the top-level keys are the namespaces”components.json declares "$namespace": "", so the top-level keys are component namespaces and the full paths are simply button.height.medium, input.borderRadius:
{ "$namespace": "", "$type": "dimension", "button": { "height": { "medium": { "value": "40px" } } }}Where namespaces take effect
Section titled “Where namespaces take effect”dist/docs/tokens.mdsplits into##sections by top-level namespace (button / color / motion / zIndex, …)- The resolve stage does duplicate detection on full paths: two light files declaring the same path is a hard error
- Dark-mode merging matches override keys by full path
- Every target builds nested structures by splitting the path segments (Android
object Color, Swiftenum Color, CLH_COLOR_*)
Complete example
Section titled “Complete example”color.primary.active ← color.jsonbutton.height.medium ← components.json (empty-string namespace)typography.fontSize.base ← typography.jsonzIndex.modal ← z-index.json (explicit)motion.easing.easeInOut ← motion.json (grouped nesting)The Token Reference page lets you browse every token by namespace.
Copyright © 2024-2026 FengMo WenXue