Visual design · Step 3 · 8 min read
Semantic colour and state
How to give each colour in your palette a semantic role — surface, on-surface, primary, secondary, status — and use state variations (hover, active, disabled) without adding new colours to the system.
A palette without function is decoration. Here each colour gets a semantic role.
What you'll be able to do after reading:
- Distinguish a colour role from a colour token and explain why the difference matters
- Name the five semantic roles and assign colours to them from an existing palette
- Use CSS custom properties to map palette colours to semantic roles
- Derive hover, active and disabled state colours without adding new palette entries
- Identify when two roles are sharing one colour and decide whether that is acceptable
1. Colour roles and colour tokens
Before assigning colours to the interface, two terms need to be clear — because they are often confused and the confusion causes real problems in systems.
A colour role (papel de cor) is a semantic concept: "the background of a surface," "the text that sits on a surface," "the colour of the main action." A role describes what a colour does, not what it looks like.
A colour token (token de cor) is the CSS variable that stores the actual value for a role. --color-primary is a token. oklch(0.52 0.16 240) is the value assigned to it.
The two things exist on different levels. A role is a design decision; a token is the implementation. You can reassign a token's value (say, to switch from light to dark mode) without changing the role. You can rename a token without changing the role it represents. What you cannot do is skip the role layer and go straight from palette to code — if you do, every change to the palette requires hunting down every use in the CSS.
For the full implementation detail — tiers, naming conventions, how tokens compose in a design system — see Colour, type and spacing as tokens.
2. The five semantic roles
The five roles cover almost every surface in a UI:
| Role | OKLCH (light mode) | What it is |
|---|---|---|
| Surface | oklch(0.97 0.01 240) |
The background a component sits on — not "background" (a CSS property); the design concept of the surface beneath content |
| On-surface | oklch(0.14 0.015 240) |
Text, icons, borders that sit on the surface |
| Primary | oklch(0.52 0.16 240) |
The main interactive colour — buttons, links, the selected state |
| Secondary | oklch(0.95 0.03 240) |
Supporting highlight — selected rows, chips, focus backgrounds |
| Status | Green / Amber / Red / Blue | Feedback and state — always used with a label, never colour alone |
Surface and on-surface are the most used pair. Every time you place text on a background, you are using this pair. The word "background" is left for CSS; in design vocabulary, say "surface."
On-surface is whatever sits on a surface. That includes text, icons, borders and dividers. When the surface changes (say, from N10 to N20 in a card header), the on-surface colour may need to change too — or not, if the contrast is still sufficient.
Primary appears where there is one clear action. In Gale Console, the "New work order" button is primary. So is an underlined link in a paragraph. If two elements on the same screen both use the primary colour, one of them should probably use the secondary or a neutral.
Secondary is for highlight without emphasis. A selected row in a table, a chip showing a filter, a focus background — these need to be visually distinct from the surface without competing with the primary action. In Gale, oklch(0.95 0.03 240) is blue-tinted enough to read as "selected" but light enough not to draw the eye away from the content.
Status colours carry a fixed meaning. Using green for a "new feature" badge in one part of the app and for "work order complete" in another breaks the system. Reserve each status colour for one meaning.
3. How states use colour
A state is a temporary condition of an interactive element: default, hover, active (pressed), focused, disabled. Each state needs to look different, but you do not need a new palette entry for each one — you derive the state colours from the existing ones.
Hover: Mix the base colour with a small amount of ink (the text colour). color-mix(in oklch, var(--vd-blue) 85%, var(--vd-n90)) gives a slightly darker blue that reads as "responding to the pointer" without introducing a new hue. 85% base, 15% ink is a reasonable starting point; adjust to taste.
Active (pressed): Darken further — something like 70% base, 30% ink. The pressed state should feel clearly different from hover; if hover and active look the same, the interaction has no momentum.
Focus: A visible outline around the element, not a colour change to the element itself. Use the primary colour at full opacity, 2–3px wide, with a 2px offset from the element's border. outline: 2px solid var(--vd-blue); outline-offset: 2px; A focus outline needs to meet the same contrast requirement as text: at least 3:1 against the adjacent surface (WCAG 2.2, SC 1.4.11).
Disabled: Reduce opacity — 40% is a common value that signals "unavailable" without hiding the element. The disabled state is explicitly exempt from colour contrast requirements in WCAG 2.2 (SC 1.4.3), which is why N40 at oklch(0.60 0.02 240) can appear as disabled text even though its contrast against white is below 4.5:1.
:root {
/* Semantic tokens — light mode */
--color-surface: oklch(0.97 0.01 240);
--color-on-surface: oklch(0.14 0.015 240);
--color-primary: oklch(0.52 0.16 240);
--color-secondary: oklch(0.95 0.03 240);
/* State derivations */
--color-primary-hover: color-mix(in oklch, var(--color-primary) 85%, oklch(0.14 0.015 240));
--color-primary-active: color-mix(in oklch, var(--color-primary) 70%, oklch(0.14 0.015 240));
--color-disabled-text: oklch(0.60 0.02 240); /* N40 — exempt from contrast req. */
}
4. Mapping the full palette to roles
A complete role-to-token mapping for Gale Console, light mode:
:root {
/* Surfaces */
--color-surface: oklch(0.97 0.01 240); /* page, card background */
--color-surface-raised: oklch(0.97 0.01 240); /* same in this design */
--color-surface-sunken: oklch(0.88 0.015 240); /* input background */
--color-on-surface: oklch(0.14 0.015 240); /* primary text */
--color-on-surface-muted: oklch(0.30 0.02 240); /* secondary text */
--color-border: oklch(0.88 0.015 240); /* dividers */
/* Interactive */
--color-primary: oklch(0.52 0.16 240);
--color-on-primary: oklch(0.99 0 0); /* white text on button */
--color-secondary: oklch(0.95 0.03 240);
/* Status */
--color-success: oklch(0.55 0.17 145);
--color-warning: oklch(0.65 0.18 70);
--color-danger: oklch(0.52 0.22 25);
--color-info: oklch(0.52 0.16 240); /* same as primary */
}
One thing to notice: --color-info and --color-primary have the same value. That is acceptable when the informational status and the primary action share the same meaning in this product — Gale Blue reads as both "action" and "informational feedback." If a product needs to separate them visually, they should be different palette entries.
With the roles defined, we can flip the system to dark mode — without losing contrast.
5. Common mistakes
- Calling the token "background." Use
--color-surfaceor--color-bg-page. Reserve the word "background" for the CSS property; in design vocabulary, the surface is a named role. - Using the primary colour for status. If Gale Blue is both the action colour and the informational status colour, that is a deliberate choice. Using it also for warning or danger turns primary into "general attention" — which means nothing.
- Hover states that only change opacity.
opacity: 0.8on a hover reads as a glitch, not feedback. Mix the colour with a direction (lighter or darker) to show the hover intent clearly. - No focus state. Visible focus is not optional — it is required by WCAG 2.1 SC 2.4.7 (minimum AA) and 2.4.11 (AA in WCAG 2.2). Every interactive element needs a visible outline or equivalent.
- Role and token names that describe the colour, not the function.
--color-bluesays what it is;--color-primarysays what it does. When the primary colour changes from blue to teal,--color-bluebecomes a lie.--color-primarystays correct.
6. Vocabulary
| Term | Meaning |
|---|---|
| Colour role (papel de cor) | The semantic function of a colour in the system — surface, primary, status. Describes what a colour does, not what it looks like |
| Colour token (token de cor) | The CSS variable that holds the value for a colour role — --color-primary: oklch(…) |
| Surface | The colour of the background a component sits on. Never called "background" in design vocabulary (reserve that word for the CSS property) |
| On-surface | The colour of content (text, icons, borders) placed on a surface |
7. Try it
Use the Gale card in the figure above. The figure shows a list of work orders with coloured status badges. The card uses five roles: surface, on-surface, primary, secondary, and status.
- Write down which OKLCH value from Gale's palette corresponds to each role in the card:
- Surface: ?
- On-surface (primary text): ?
- Primary (button): ?
- Secondary surface (selected row): ?
- Status — success: ?
- Now write the five CSS custom properties. Use the names from this lesson, not the palette names (N10, N90, etc.).
- The "On hold" badge uses a darker amber for text on a light amber background. Without looking at the code, write a
color-mix()expression that would generate the text colour by darkening the amber:color-mix(in oklch, oklch(0.65 0.18 70) __%, oklch(0.14 0.015 240)). What percentage gives a readable, clearly amber result?
You are done when you have five CSS custom property declarations and a color-mix() expression for the amber badge.
8. If you already practise
- Look at your current project's colour tokens. How many of them describe what a colour is (blue, light-grey-200) versus what it does (surface, primary, disabled-text)? What would it take to rename the descriptive ones to functional ones?
- Material Design 3's colour roles (m3.material.io/styles/color/roles) use a different set of names (container, on-container, etc.) but the same concept. Compare their role set with the five roles here — where do they overlap and where do they differ?
Checklist
Learn more
- W3C WCAG 2.2 — SC 1.4.11 Non-text contrast — the contrast requirement for focus indicators and UI components
- Material Design 3 — Colour roles — another naming system for semantic roles; useful to compare approaches
- MDN: color-mix() — how to derive state colours in CSS
Books, courses and videos to go deeper
- Interaction of ColorJosef AlbersBook · Yale University Press, pocket edition, 2006 · — the classic argument for why colour meaning comes from context, not from the colour itself (Amazon)
- CSS in DepthKeith GrantBook · Manning, second edition, 2023 · — custom properties, cascade and colour in CSS
Book links go to Amazon. As an Amazon Associate I earn from qualifying purchases, at no extra cost to you.
Related
Building a colour palette in OKLCH · Dark mode that actually works · Colour, type and spacing as tokens · Colour and contrast