Skip to content
IndexRequest a UIAboutContact

Semantic Colour Roles

Name colours by job (primary, success, warning, danger, surface, text) and see them swap for light and dark themes.

Open alone ↗

AI prompt

PROMPT: PASTE INTO YOUR AI IMAGE OR VIDEO TOOL
Design system documentation page showing semantic colour roles as a clean grid of rounded swatches with labels beneath: surface, text, primary blue, success green, warning amber, danger red, each with its hex value, shown twice side by side for light and dark themes, a small sample card with a primary button and a danger alert below, flat vector style, plenty of white space. Negative: gradients, shadows, unrelated hues, text errors, decorative frames. Reduced motion: static page.

About this pattern

Definition

A palette is a list of colours; a set of roles is a list of jobs. Naming colours by role (surface, text, primary, danger) lets a whole theme switch by changing the values behind the names, and keeps meaning consistent across the product.

When to use it

  • Keep a small fixed set: surface, text, muted text, primary, success, warning and danger.
  • Each role needs a light and a dark value that both pass contrast against their surface.
  • Never use the danger colour for decoration; its job is to mean error.

What the controls do

  • Light and Dark theme buttons, a table of roles with their values, and a live sample using them.

Motion & timing

  • Colours cross-fade over 200ms when the theme changes.
  • Reduced motion: instant switch.

Tips & variations

  • Test every role against its background in both themes.
  • Do not carry meaning by colour alone; pair with an icon or word.

Code of this live preview

HTML
<div class="bx"><div class="pre" id="pre" role="group" aria-label="Theme"><button data-p="0" aria-pressed="true">Light</button><button data-p="1" aria-pressed="false">Dark</button></div><div class="th" id="th"><div class="sw" id="sw"></div><div class="sm"><b>Sample card</b><span>Roles keep meaning across themes.</span><div><button type="button" class="pb">Save</button><em class="al">Payment failed</em></div></div></div></div>

Related patterns

Tint, Shade & Tone Ramps

↗
Tint, Shade & Tone RampsColour Techniques

60-30-10 Colour Rule

↗
60-30-10 Colour RulePalettes by Concept

Contrast Ratio Checker

↗
Contrast Ratio CheckerColour Techniques