When a designer picks “text subtle” in a design file and a developer writes var(--bh-color-text-subtle), they mean the same grey. That shared name is a design token. Change its value once and every product follows, so screens never drift apart.
Use a token for every colour, size, space, radius, shadow and duration. Do not type the raw value.
What a token is
A token is a name and a value. The name says what the value is for. The value can be a colour, a size, a duration or another token.
| Name | Value | What it is for |
|---|---|---|
color.text.subtle |
{color.graphite.11} |
Secondary text, such as descriptions and navigation |
space.card |
{space.300}, 24 px |
Padding inside cards and panels |
radius.control |
{radius.075}, 6 px |
Corners of buttons, text fields and selects |
motion.duration.fast |
100 ms | Small changes, such as a hover colour |
Why tokens matter
- Design and code speak the same language. A name in a design file is the same name in code, so nothing is lost in handoff.
- One change reaches every product. When a value is adjusted, every screen that uses the token updates with it.
- Themes come for free. Dark mode and Vietnamese text change token values, not your code.
- Names explain the choice.
color.border.focustells the next person why the line is blue.#005195does not.
How tokens are layered
Tokens come in three layers. Use the most specific one that fits.
| Layer | Example | Use it |
|---|---|---|
| Scale | color.graphite.11, space.200, radius.100 |
The raw steps. Colour scales are never used directly. Spacing and radius steps are used when no role token fits. |
| Role | color.text.subtle, space.control.x, radius.card |
In products and components. Each is named for its job, so it stays right when the scale changes. |
| Component | color.code.background |
Only where no role fits. |
A role token points at a step of a scale. color.text points at {color.graphite.12}, for example. Use the role token, not the step it points at: if the step changes for the role, your screen changes with it.
Reading a token name
A name reads from general to specific. Take color.background.danger.bold.hover:
| Part | Meaning |
|---|---|
color |
The kind of value |
background |
Where it is used |
danger |
What it means |
bold |
How strong it is |
hover |
The state it is for |
Not every name has every part. color.text is the default text colour. Leaving a part out means “the default”.
Design files and these docs separate the parts with dots. CSS uses hyphens and adds the bh prefix:
| Token | CSS custom property |
|---|---|
color.text |
--bh-color-text |
space.200 |
--bh-space-200 |
color.border.focus |
--bh-color-border-focus |
One name, several values
Some tokens have a different value in another context. The name stays the same, so your code does not change.
| Context | Example | What changes |
|---|---|---|
| Dark mode | elevation.shadow.raised |
The shadow gets darker so it still shows on a dark surface |
| Vietnamese text | font.body.default |
Line height grows from 20 px to 24 px so stacked accents are not clipped |
Dark mode follows the person’s system setting, unless a page sets light or dark. Vietnamese values apply to any element marked lang="vi". See Dark mode and Vietnamese.
Find the right token
- Start from the job. Is it text, a background, a border, a gap? Open the matching style page below.
- Pick the role. Choose the token named for what you are building, such as
space.control.xfor the side padding of a button. - Check the state. Hover, pressed, selected and disabled have their own tokens. See Interaction states.
- No role fits? Use a scale step for spacing or radius. For colour, ask the design system team for a new role.
| Do | Don’t |
|---|---|
Use color.text.subtle for a description under a title. |
Use color.graphite.11 because it looks the same today. |
Use space.card inside a card. |
Use 24px, or space.300 when space.card exists. |
Use color.text.danger for an error message. |
Use a danger token only because the colour is red. Tokens carry meaning, not just colour. |
| Ask for a new token when nothing fits. | Make a value close to a token, such as 15px next to space.200. |
Tokens by group
| Group | What it holds | Example |
|---|---|---|
| Color | Text, backgrounds, borders, icons and surfaces, in light and dark | color.background.brand.bold |
| Typography | Font families, sizes, weights and full text styles | font.heading.medium |
| Spacing | Space between and inside elements | space.stack |
| Size and density | Heights of controls and minimum touch targets | size.control.default |
| Radius | Corner rounding by element | radius.modal |
| Border | Line widths | border.width.focused |
| Elevation | Shadows that lift surfaces | elevation.shadow.raised |
| Opacity | See-through values | opacity.disabled |
| Z-index | Stacking order of layers | z-index.modal |
| Motion | Durations and easing | motion.easing.enter |
| Layout | Page widths, margins, breakpoints and overlay widths | layout.page.wide |
One source
Every token has one value, kept in one place. The token tables on this site and the CSS custom properties in products come from that same source, so they always match.
The package @beehexa/design-tokens carries that source in three forms:
| Form | Path in the package | Use it for |
|---|---|---|
| CSS custom properties | @beehexa/design-tokens/css |
Product code: every token as --bh-*, light and dark |
| Typed JavaScript | @beehexa/design-tokens |
Code that needs a value, such as a chart or an editor |
| DTCG JSON, one file per group | @beehexa/design-tokens/dtcg/color.json, …/spacing.json and the rest |
Other tools: build tools such as Style Dictionary, and design tool plugins. The files follow the Design Tokens Format Module |
Related
- All design tokens: every token with its light and dark value
- Develop: how to add the tokens to a product
- Interaction states: tokens for hover, pressed, selected and disabled