Sub topic 4
Building the Neutral Colours
This chapter assumes you can write CSS custom properties and read hsl() values. It also assumes you know the three colour roles from earlier in the tutorial. By the end you will have a tinted neutral scale for text, surfaces, and borders. You will also know how to check that its steps are usable.
Why neutrals do most of the work
Neutral colours are greys, or near-greys, with little or no visible hue. On a typical interface they cover far more area than the primary or accent colours. Page backgrounds, cards, body text, headings, dividers, input borders, and disabled controls are all neutral.
Because of this, the neutral scale decides how the site feels. It also decides how readable the site is. A weak primary colour affects buttons and links. A weak neutral scale affects every paragraph on every page.
Neutrals have three jobs:
- Surfaces: the page background, cards, panels, and table stripes.
- Text: body copy, headings, captions, and placeholder text.
- Structure: borders, dividers, and focus-free outlines.
Each job needs several steps on the scale. A single grey is not enough.
Pure grey versus tinted neutral
A pure grey has equal red, green, and blue values, for example hsl(0 0% 50%). A tinted neutral has a small amount of saturation, so it leans slightly toward a hue.
Tinted neutrals usually look more polished when placed next to a coloured brand colour. A pure grey beside a saturated blue can look slightly warm or dull by contrast. The eye compares colours with their surroundings. A grey with a trace of the primary hue looks like it belongs to the same family.
The usual approach is:
- Take the hue of your primary colour. In this tutorial that is 220, a blue.
- Use that hue for every neutral step.
- Keep saturation low, roughly 5% to 20%.
The saturation you can get away with depends on lightness. At very light values, 15% saturation is almost invisible. At dark values, the same percentage is more noticeable. That is why the dark steps below use a slightly higher saturation than the middle steps.
Warm, cool, and neutral tints
You can choose the tint direction on purpose.
| Tint | Hue range | Feel | Typical use |
|---|---|---|---|
| Cool | 200 to 240 | Technical, calm, clean | Dashboards, developer tools, finance |
| Warm | 30 to 60 | Friendly, paper-like | Editorial sites, journals, lifestyle |
| Pure grey | any, 0% saturation | Flat, impartial | Print-style layouts, data-heavy tables |
If your primary colour is blue, a cool tint matches it. If your primary is a green or a red, you could still tint neutrals toward a warm or cool direction. The only real rule is to pick one tint and use it for the whole scale. Mixing a blue-tinted grey for text with a warm-tinted grey for backgrounds produces a muddy page that is hard to explain.
Choosing the steps
A neutral scale commonly has 8 to 11 steps. You do not need to fill every number. Define the steps that your design uses, and leave gaps in the numbering so you can add steps later without renaming.
The numbering follows lightness. A low number is light and a high number is dark. The numbers here are labels, not percentages.
| Step | Lightness | Saturation | Typical role |
|---|---|---|---|
| 50 | 97% | 15% | Page background |
| 100 | 94% | 15% | Cards, table stripes, hover surfaces |
| 200 | 88% | 13% | Subtle dividers, disabled backgrounds |
| 300 | 80% | 12% | Borders on cards and panels |
| 500 | 55% | 10% | Placeholder text, icons (large only) |
| 700 | 28% | 15% | Secondary text, captions |
| 900 | 12% | 20% | Body text and headings |
Steps 50, 300, 700, and 900 match the palette in the earlier code example. Steps 100, 200, and 500 fill the gaps that surfaces and placeholders need.
Why the steps are uneven
The lightness gaps are not equal. Between 50 and 100 the gap is 3 points. Between 500 and 700 it is 27 points. This is deliberate.
- Light surfaces sit close together. A card should be only just different from the page behind it. A large jump looks heavy.
- Text steps need distance from the background. The contrast between text and surface drives readability, so the dark end needs to be far from the light end.
- The middle of the scale is used least, so it can be sparse.
If you spaced every step by an equal amount, you would get too many mid-greys that no component uses and too few usable light surfaces.
Defining the neutrals in CSS
Here is the neutral section of the palette from the earlier chapter, extended with the extra steps.
:root {
/* Neutral: low saturation, tinted toward the primary hue (220) */
--neutral-50: hsl(220 15% 97%);
--neutral-100: hsl(220 15% 94%);
--neutral-200: hsl(220 13% 88%);
--neutral-300: hsl(220 12% 80%);
--neutral-500: hsl(220 10% 55%);
--neutral-700: hsl(220 15% 28%);
--neutral-900: hsl(220 20% 12%);
}Notice that the hue is repeated in every line. If you change your primary hue later, you must change this number in several places. In a later chapter you will see how to centralise this. For now, a generator script is a cheaper way to avoid typos.
Generating the scale with a script
This Node.js script prints the custom properties from one hue value and a table of steps. Run it with node neutrals.js. Change hue to retint the whole scale.
const hue = 220;
const steps = [
{ name: 50, saturation: 15, lightness: 97 },
{ name: 100, saturation: 15, lightness: 94 },
{ name: 200, saturation: 13, lightness: 88 },
{ name: 300, saturation: 12, lightness: 80 },
{ name: 500, saturation: 10, lightness: 55 },
{ name: 700, saturation: 15, lightness: 28 },
{ name: 900, saturation: 20, lightness: 12 },
];
const lines = steps.map(
(s) => ` --neutral-${s.name}: hsl(${hue} ${s.saturation}% ${s.lightness}%);`
);
console.log(":root {\n" + lines.join("\n") + "\n}");The output is a ready-to-paste :root block. Keeping the step table in one place makes it easy to review the numbers as a set rather than as scattered CSS lines.
Checking the neutrals
The contrast chapter later in this tutorial covers WCAG in detail. Even so, you should sanity-check the neutral scale as you build it, because many contrast failures come from neutrals. Here are approximate ratios for this scale, calculated with the WCAG 2 formula.
| Foreground | Background | Approximate ratio | Verdict |
|---|---|---|---|
| neutral-900 | neutral-50 | above 15:1 | Passes for all text |
| neutral-700 | neutral-50 | about 9:1 | Passes for all text |
| neutral-300 | neutral-50 | about 1.5:1 | Fails for text and for input borders |
Two lessons follow from the table.
First, the body text and secondary text steps are safe. Even secondary text at step 700 has a comfortable margin over the 4.5:1 threshold for normal text.
Second, step 300 is fine for decorative card edges and dividers, but it is too faint to serve as the only visible boundary of a form field. WCAG asks for 3:1 against the adjacent colour for user-interface components that someone must perceive to use. A text input whose only border is step 300 may be hard to see for people with low vision. For inputs, use a darker border such as step 500 or darker. Check it with the contrast function from the accessibility chapter, because step 500 at 55% lightness sits close to the 3:1 line on a light background.
Common errors
These are the problems that show up most often when people build neutrals.
- Using pure black text.
#000on#fffhas a contrast of 21:1, which is the maximum. That can produce glare on large screens, and some readers find it tiring. A very dark tinted neutral such as step 900 gives plenty of contrast and reads softer. - A page background of pure white. This leaves no lighter step to use for raised surfaces. If the page is step 50, a card can be white (or step 100 for a recessed panel) and still show a difference. Pick the page background with room to move in both directions.
- Too many close steps. Two greys that differ by 1 or 2 lightness points will not be distinguishable on many displays. Keep adjacent steps at least 3 points apart, and in practice more.
- Tint saturation that is too high. At 40% saturation, a "neutral" reads as a pale colour. It then competes with the primary colour for attention. If you can name the colour of a neutral, it has too much saturation.
- Placeholder text on step 300 or lighter. Placeholder text is still text. It needs 4.5:1 against the field background, so choose a darker step such as 700.
- Referencing steps directly in components. If a card uses
var(--neutral-300)everywhere, a palette change forces you to hunt through the stylesheet. The semantic layer, such as--color-border, solves this. It is covered in the tokens chapter.
Where the neutrals go next
The neutral scale is the backbone for what follows. The proportion chapter uses it to explain why the largest share of the page should be neutral. The scales chapter builds the same kind of lightness ladder for the primary and accent hues. The dark-mode chapter swaps neutral steps so that text becomes light and surfaces become dark, which is easier because you named the steps by role.
Exercise
A teammate wants form field borders to use --neutral-300 (about 1.5:1 against the page background) so that forms look light and airy. What should you tell them, and which step would you try instead?
Show answer
WCAG expects user-interface components that a person must see to use, such as input borders, to have at least 3:1 contrast against the adjacent colour. At about 1.5:1, step 300 fails and the field may be hard to find for people with low vision. Keep step 300 for decorative edges such as card borders and dividers. For input borders, try a darker step such as --neutral-500, then measure it with a contrast function. If it falls below 3:1, move to a darker step such as --neutral-700.
Exercise
You change your primary colour from hue 220 (blue) to hue 160 (green). What must you change in the neutral scale so it still matches, and what can stay the same?
Show answer
Change the hue value in every neutral step from 220 to 160, or change the single hue constant if you use the generator script. The saturation and lightness values can stay the same, because they control how strong the tint is and how light each step is, not which colour it leans toward. After the change, re-check the text steps against the backgrounds, because a different hue shifts the computed luminance slightly.