Color and design guides

Build Light and Dark Color Tokens

·

A design token gives a color a reusable name. Apply the same role in light and dark themes while each theme assigns its own value.

Design System Color Tokens

Check the Primary variants in the light theme

Choose Harbor colors and keep Primary color at #336699. Set Preview theme to Light and Preview role to Primary. Base is the input. Light blends 80% white into the input and Hover blends 14% black into it.

The panel reports the contrast for Text on Base. Switch to Dark to see the role adapt to that theme. If you enter a translucent source, the light tokens blend it over white and the dark tokens blend the adapted color over #171C24.

Check the Primary variants in the light theme
Light tokenExpected value
base#336699
light#D6E0EB
hover#2C5884
text#FFFFFF

CSS Color Module Level 4 sRGB color and alphaWCAG 2.2 contrast ratio definitionDesign Tokens Community Group format terminology

Compare the same theme in CSS and JSON

Download CSS variables and JSON tokens. The JSON groups the values by theme and role. Check light.primary.base and dark.primary.base against --color-primary-base in the matching CSS blocks.

Use var(--color-primary-base) for a button background and var(--color-primary-text) for its label. Add data-theme=dark to the containing element to switch to the alternate pair. If you use Hover as the background later, measure the text contrast for that pairing as well.

CSS Custom Properties Level 1WCAG 2.2 contrast ratio definition

Common questions

Which roles can I set?

Primary, secondary, accent, success, warning, error and info each begin with their own input color.

When do a token's color values change?

Changing a source color recalculates its variants in both themes. Each CSS selector selects one set of values for its descendants.

Sources

Put it into practice.

Related guides