Skip to main content
Login

Sign in to access your account

Tokens - National Design System

The CSS custom properties behind NDS: the color palette, size scales, semantic meanings and component tokens that you read and override in your own CSS

Overview

A token is a CSS custom property that NDS defines at :root, in four tiers. Semantic tokens read the palette. Component tokens read a semantic or a palette token. A change low in the chain reaches every token that reads it.

  • Palette: the raw colors, such as --colors-primary-600. A theme replaces the four brand ramps. Base, the alphas and the status hues stay fixed.
  • Primitives: the sizes, such as --spacing-xl: spacing, radius, typography, the font, the page shell and the transition.
  • Semantic: one meaning each, system-wide, such as --text-error. The value is a palette token.
  • Component: one component’s own dial, such as --button-background-primary-default. The value is a semantic or palette token.

Pick another page when:

  • you change the brand colors of the whole site: Themes
  • you restyle one component: the Tokens table in that component’s API
  • you style one element of a component: the CSS Custom Properties table in that component’s API

Markup

Preview
primary
25 50 100 200 300 400 500 600 700 800 900 950
primary-alpha
10 20 30 40 50 60 70 80 90 100
secondary
25 50 100 200 300 400 500 600 700 800 900 950
tertiary
25 50 100 200 300 400 500 600 700 800 900 950
neutral
25 50 100 200 300 400 500 600 700 750 800 850 900 950
:root { /* Brand slot: primary */ --colors-primary-25: #f7fdf9; --colors-primary-50: #f3fcf6; --colors-primary-100: #dff6e7; --colors-primary-200: #b8eacb; --colors-primary-300: #88d8ad; --colors-primary-400: #54c08a; --colors-primary-500: #25935f; --colors-primary-600: #1b8354; --colors-primary-700: #166a45; --colors-primary-800: #14573a; --colors-primary-900: #104631; --colors-primary-950: #092a1e; --colors-primary-alpha-10: #1b835419; --colors-primary-alpha-20: #1b835433; --colors-primary-alpha-30: #1b83544c; --colors-primary-alpha-40: #1b835466; --colors-primary-alpha-50: #1b83547f; --colors-primary-alpha-60: #1b835499; --colors-primary-alpha-70: #1b8354b2; --colors-primary-alpha-80: #1b8354cc; --colors-primary-alpha-90: #1b8354e5; --colors-primary-alpha-100: var(--colors-primary-600); /* Brand slot: secondary */ --colors-secondary-25: #fffef7; --colors-secondary-50: #fffef2; --colors-secondary-100: #fffce6; --colors-secondary-200: #fcf3bd; --colors-secondary-300: #fae996; --colors-secondary-400: #f7d54d; --colors-secondary-500: #f5bd02; --colors-secondary-600: #dba102; --colors-secondary-700: #b87b02; --colors-secondary-800: #945c01; --colors-secondary-900: #6e3c00; --colors-secondary-950: #472400; /* Brand slot: tertiary */ --colors-tertiary-25: #fefcff; --colors-tertiary-50: #f9f5fa; --colors-tertiary-100: #f2e9f5; --colors-tertiary-200: #e1cce8; --colors-tertiary-300: #ccadd9; --colors-tertiary-400: #a57bba; --colors-tertiary-500: #80519f; --colors-tertiary-600: #6d428f; --colors-tertiary-700: #532d75; --colors-tertiary-800: #3d1d5e; --colors-tertiary-900: #281047; --colors-tertiary-950: #16072e; /* Brand slot: neutral */ --colors-neutral-25: #fcfcfd; --colors-neutral-50: #f9fafb; --colors-neutral-100: #f3f4f6; --colors-neutral-200: #e5e7eb; --colors-neutral-300: #d2d6db; --colors-neutral-400: #9da4ae; --colors-neutral-500: #6c727e; --colors-neutral-600: #4d5761; --colors-neutral-700: #384250; --colors-neutral-750: #2b3643; --colors-neutral-800: #1f2a37; --colors-neutral-850: #18212f; --colors-neutral-900: #111927; --colors-neutral-950: #0c111b; }

Behavior

Knobs

A knob styles one element, such as --btn-size. It is undefined by default, and the component falls back to its own value. Set it in the element’s style or on a class. A knob set on a wrapper reaches every component inside.

Resolution Chain

A painted value goes down a chain from a knob to the palette. Change any token in the chain, and everything above it follows.

/* The primary button fill: knob, component token, palette */ --btn-bg: var(--button-background-primary-default); /* knob, set by .nds-primary */ --button-background-primary-default: var(--colors-primary-600); /* component token */ --colors-primary-600: #1b8354; /* palette */ /* The checked checkbox fill: component token, semantic token, palette */ --checkbox-primary-checked: var(--controls-primary-checked); /* component token */ --controls-primary-checked: var(--colors-primary-600); /* semantic token */

Dark Mode

data-theme="dark" on <html> switches the semantic and component tokens to their dark values. On any other element, it makes that element a dark area: both tiers are declared again on it, with dark values. Some components also have dark rules of their own. Switching and saving the mode is on the Themes page.

Override Scope

A token that reads another token takes its value where it is declared. The semantic and component tokens are declared at :root, so they read the palette there. A palette token set on a wrapper does not change them. On a wrapper, set the token that the component reads.

To change a token on every page, set it in your own stylesheet, loaded after nds-main.min.css. Repeat both NDS selectors: a dark area declares every token again with the NDS values, so a plain :root rule does not reach it. Give the override a dark value too, or dark mode shows the NDS one. A pack’s code has both rules: copy it and keep only the lines you change.

/* Light mode. Dark areas match too, which keeps your value there for a token with no dark value */ :root, [data-theme~="dark"]:not(:root) { --background-card: #fffdf5; } /* Dark mode and dark areas. This rule comes last, so a dark area takes its value */ :root[data-theme~="dark"], [data-theme~="dark"]:not(:root) { --background-card: #26221a; }

Built-in Features

  • Fluid Typography

    The --typo-display-clamp-* and --typo-text-clamp-* sizes grow with the screen width, between a minimum and a maximum.

  • Font Sizing

    Every font size and line height multiplies by --user-font-scale, which the Accessibility panel sets on <html>. It works there only: the tokens resolve on the root.

  • Phone Padding

    --nds-viewport-padding is 32px, and half of that below 600px. Menus and tooltips keep the same space from the sides of the screen, so they line up with the page content.

  • Weights per Theme

    The themes with a font of their own, Cairo or Readex Pro, set the --font-weight-* tokens one step lower: 300 to 600.

Best Practices

  • Use an NDS component before you style an element of your own. Tokens are for the CSS you write.
  • Write var(--token) for every color, size and shadow. Never write a hex value or a pixel size that a token names.
  • In your own CSS, pick a semantic token by its meaning. Do not read a component token because its value matches today: it can change with that component.
  • Use a palette token only when no semantic token has the meaning. Take every state of a family from the same tier.
  • Pair each font size with its line height: --typo-text-md-FS with --typo-text-md-LH.
  • To restyle one component in one place, set its component tokens on a wrapper. Set every state of the family, or the hover color stays the old one.
  • Set palette tokens at :root only. On a wrapper, they do not reach the tokens that read them.
  • To change the brand colors, use a theme from the Themes page: seed colors, or a stylesheet that sets every step of a ramp. Do not change one step of a ramp alone.

API

Name Patterns

A semantic or component name says what the value is for. It never names a color or a shade number.

Tier Pattern Example
Semantic --{property}-{role}-{modifier}-{state} --text-oncolor-primary, --background-error-light
Component --{component}-{property}-{variant}-{state} --button-background-primary-hovered

Name Parts

Part Meaning
primary, secondary, tertiary, neutral The brand and neutral roles
success, info, warning, error The status roles. Each has background, text, border and icon tokens
light A tint of the base meaning, for soft surfaces and borders
faint The lightest tint, one step below light
strong A deep, stronger form of the base meaning
oncolor For an element on a colored or dark fill. It does not change in dark mode. It comes last, before the state
default, hovered, pressed, selected, focused, disabled, checked The state. A name with no state is the resting state. pressed is the :active state
Last Modified Date: 05/11/2026 - 11:25 AM
Was this page useful?
60% of users said Yes from 2843 Feedbacks