Skip to content

Add a Token

Steps

1. Determine the layer

LayerWhen to useExample
PrimitiveNew color palette value, spacing step, or font propertycolor.purple.400
SemanticNew functional alias that maps to a primitivecolor.status-info
ComponentToken scoped to a specific componentbadge.bg

2. Add to source JSON

Edit the appropriate file in packages/tokens/src/:

src/
├── primitives/
│ ├── color.json ← palette colors
│ ├── spacing.json ← spacing scale
│ ├── radius.json ← border radius
│ └── ...
├── semantic/
│ ├── color.json ← functional color aliases
│ ├── elevation.json ← box shadows
│ └── typography.json ← composite type styles
└── component/
├── button.json
├── card.json
└── input.json

For color tokens, provide both oklch and hex values:

{
"purple": {
"400": {
"$type": "color",
"$value": {
"oklch": "0.68 0.17 300",
"hex": "#A77BDB"
}
}
}
}

3. Build and verify

Terminal window
pnpm build
pnpm test:parity # verify oklch ↔ hex parity

4. Check outputs

  • CSS: dist/css/tokens.css
  • Dart: dist/dart/verdanta_tokens.dart
  • Figma: dist/figma/variables.verdanta.json

5. Brand overrides (if needed)

If GetPlants needs a different value for this token (semantic or component only):

  1. Add the override in src/brands/getplants.json
  2. Rebuild: pnpm build
  3. Verify: dist/css/getplants.css and dist/figma/variables.getplants.json

6. Update docs

Terminal window
node packages/tokens/scripts/docs.mjs

This regenerates the Token Reference page.

7. Push to Figma (optional)

Terminal window
pnpm figma:sync:dry # preview changes
pnpm figma:sync # push to Figma