Design Tokens

Raw
GuidancelatestAnt Design 5.xRetrieved 2026-05-13

Design Token Architecture

Source: ant.design/docs/react/customize-theme

Ant Design 5.x uses a three-layer algorithmic token architecture. The key insight is that changing a small number of "seed" values automatically propagates through a derivation algorithm to update dozens of dependent tokens — making system-wide visual changes low-effort and consistent.


Three-layer architecture

Seed Tokens
    ↓ (algorithm)
Map Tokens
    ↓ (aliasing)
Alias Tokens
    ↓
Component Tokens

Seed Tokens

High-level design intentions — the inputs you control. Examples:

Seed TokenDefaultWhat it controls
colorPrimary#1677ffBrand color; drives all primary interactive states
colorSuccess#52c41aSuccess state color
colorWarning#faad14Warning state color
colorError#ff4d4fError / danger color
colorInfo#1677ffInformational color
borderRadius6Base border-radius; drives SM/LG/XS variants
fontSize14Base font size; drives heading scale
motiontrueEnable / disable all animations

Most customization needs can be met at the seed level alone.

Map Tokens

Derived values computed algorithmically from seed tokens. You generally do not set these directly — they are calculated from seed inputs via the preset algorithm. They represent the full expanded token vocabulary: hover colors, active colors, disabled states, border variants, etc.

Alias Tokens

Named references to map tokens, used as the actual values in component styles. For example, colorText is an alias that points to a specific map token for primary text. You can override alias tokens when you need to break the derivation pattern for specific roles.


ConfigProvider

All token customization is applied through the <ConfigProvider> component:

import { ConfigProvider } from 'antd';

function App() {
  return (
    <ConfigProvider
      theme={{
        token: {
          colorPrimary: '#your-brand',
          borderRadius: 4,
          fontSize: 14,
        },
      }}
    >
      <YourApp />
    </ConfigProvider>
  );
}

Limitation: Static methods (message.success(), Modal.confirm(), notification.open()) do not inherit ConfigProvider context. Use Modal.useModal() or wrap with the App component from antd.


Preset algorithms

Ant Design ships three built-in derivation algorithms:

AlgorithmEffect
theme.defaultAlgorithmStandard light appearance — the default
theme.darkAlgorithmDark mode — recalculates all derived tokens for dark surfaces
theme.compactAlgorithmCompact density — reduces controlHeight and spacing proportionally

Algorithms can be combined:

import { theme } from 'antd';

<ConfigProvider
  theme={{
    algorithm: [theme.darkAlgorithm, theme.compactAlgorithm],
  }}
>

Component-level tokens

Override tokens for a specific component without affecting others:

<ConfigProvider
  theme={{
    components: {
      Button: {
        colorPrimary: '#custom-color',
        borderRadius: 2,
        algorithm: true,  // re-derive hover/active from this seed
      },
      Table: {
        colorBgContainer: '#fafafa',
      },
    },
  }}
>

Setting algorithm: true on a component token tells the system to re-run the derivation algorithm from the overridden seed rather than using the static value directly.


Consuming tokens in components

import { theme } from 'antd';

const MyComponent = () => {
  const { token } = theme.useToken();

  return (
    <div style={{
      color: token.colorText,
      background: token.colorBgContainer,
      borderRadius: token.borderRadius,
      padding: `${token.paddingMD}px ${token.paddingLG}px`,
    }}>
      ...
    </div>
  );
};

For static contexts outside React lifecycle:

const globalToken = theme.getDesignToken();

Full token vocabulary

Color tokens

CategoryKey tokens
SemanticcolorPrimary, colorSuccess, colorWarning, colorError, colorInfo
TextcolorText, colorTextSecondary, colorTextTertiary, colorTextQuaternary, colorTextDisabled
BackgroundcolorBgContainer, colorBgElevated, colorBgLayout, colorBgMask
BordercolorBorder, colorBorderSecondary, colorBorderDisabled
FillcolorFill, colorFillSecondary, colorFillTertiary, colorFillQuaternary

Size tokens

TokenDefaultMeaning
controlHeight32Default control height (input, button)
controlHeightLG40Large control height
controlHeightSM24Small control height
controlHeightXS16Extra-small control height
fontSize14Base font size

Spacing tokens

Margin and padding tokens use size suffixes: XXS, XS, SM, MD (base), LG, XL, XXL.

Example: token.marginMD (base margin), token.paddingLG (large padding).

Radius tokens

TokenDefault
borderRadius6
borderRadiusLG8
borderRadiusSM4
borderRadiusXS2

Motion tokens

TokenDefaultMeaning
motiontrueEnable / disable all animations
motionUnit0.1Duration increment (seconds)
motionBase0Base duration offset
motionEaseInOutcubic-bezier(0.645, 0.045, 0.355, 1)Standard easing
motionEaseOutBackcubic-bezier(0.12, 0.4, 0.29, 1.46)Overshoot easing

Shadow tokens

TokenUsage
boxShadowPrimary elevation (popovers, dropdowns)
boxShadowSecondarySecondary elevation
boxShadowTertiarySubtle elevation

Breakpoints

Tokenpx value
screenXS480
screenSM576
screenMD768
screenLG992
screenXL1200
screenXXL1600

Nested themes

Nest ConfigProvider components to apply localized themes to sections of the UI. Child themes inherit all unmodified parent tokens — only explicitly overridden tokens change:

<ConfigProvider theme={{ token: { colorPrimary: '#blue' } }}>
  <MainContent />
  <ConfigProvider theme={{ token: { colorPrimary: '#red' } }}>
    <DangerZone />  {/* red primary, all other tokens inherited from parent */}
  </ConfigProvider>
</ConfigProvider>

Architecture comparison

SystemToken layersDerivation model
Ant Design 5.xSeed → Map → Alias → ComponentAlgorithmic — seed drives derivatives
Material 3Reference → System → ComponentAlgorithmic (HCT tonal palettes)
CarbonPrimitive → SemanticManual mapping, no algorithm
AtlassianAll-semantic (no primitive exposed)Manual, role + emphasis + state naming
Radix ThemesConfig props → CSS variablesConfig-first, no traditional token vocabulary