Sub topic 4
Building the neutral colours
This chapter assumes you can write CSS custom properties, read HSL values, and have chosen a primary colour. Here we build the neutral scale that the rest of the palette sits on.
Why neutrals do most of the work
Neutrals are the low-saturation colours used for backgrounds, cards, borders, dividers, and text. On a typical page they cover most of the pixels. The primary and accent colours only mark the places where you want attention.
Because neutrals are everywhere, small mistakes in them are visible everywhere. A neutral that clashes with the primary colour makes the whole page look slightly off.
Neutral does not mean pure grey
A pure grey has zero saturation, so it carries no hue. Next to a saturated blue it can look dead or slightly warm. A common fix is to tint the neutrals toward the primary hue with a small amount of saturation.
The primary in this tutorial uses hue 220. The neutrals reuse that hue with saturation between 10% and 20%. Nobody will name the tint as blue, but the page feels more consistent.
:root {
--neutral-50: hsl(220 15% 97%);
--neutral-100: hsl(220 14% 93%);
--neutral-300: hsl(220 12% 80%);
--neutral-500: hsl(220 10% 50%);
--neutral-700: hsl(220 15% 28%);
--neutral-900: hsl(220 20% 12%);
}Only lightness changes a lot between steps. Hue stays fixed and saturation moves a few points. Saturation is slightly higher at the dark end because very dark, low-saturation colours look flat.
Assigning steps to jobs
Each part of the scale has a typical use. Decide these roles before you add more steps.
| Step | Lightness | Typical use |
|---|---|---|
| 50 | 97% | Page background |
| 100 | 93% | Cards, table stripes, input backgrounds |
| 300 | 80% | Decorative borders, dividers |
| 500 | 50% | Secondary text, icons |
| 700 | 28% | Body text on light surfaces, strong borders |
| 900 | 12% | Headings, primary text |
The scale is a ladder of lightness, so the roles follow from that order. Surfaces are at the light end. Text is at the dark end. Borders sit in between, close enough to the surface to stay quiet.
Avoid pure black and pure white
Text in #000 on a #fff background has the maximum possible contrast. On bright screens this can feel harsh, and long reading sessions get tiring. Using --neutral-900 on --neutral-50 still gives a very high ratio. It looks softer and keeps the tint consistent.
A white surface is still useful. Cards on a --neutral-50 page can be pure white to lift them slightly. Treat white as a deliberate exception, not the default background.
Choosing the number of steps
Six steps is enough to start. More steps help once you have real components, such as a hover state for a table row that needs a shade between 100 and 300. Add steps when a component needs one, not in advance. Each extra step is another value to document and test.
Common errors
- Using the same border step everywhere.
--neutral-300works for a card outline. It has far too little contrast against a light background to mark the edge of a text input. WCAG 2.1 asks for 3:1 on UI components that identify controls, so form fields need a darker border such as--neutral-500or--neutral-700. - Making secondary text too light. Step 500 is a starting point, not a guarantee. You must check its contrast against each surface it sits on. The contrast chapter shows how.
- Mixing tints. Taking one neutral from a warm grey palette and another from a cool one produces visible mismatches. Keep one hue for the whole scale.
- Skipping the dark end. If your darkest neutral is 40% lightness, text will always look washed out.
Using the scale
Components should not reference these steps directly. A later chapter adds semantic names such as --color-text on top. For now, you can test the scale in a plain stylesheet.
body {
background: var(--neutral-50);
color: var(--neutral-900);
}
.card {
background: #fff;
border: 1px solid var(--neutral-300);
}
.card .meta {
color: var(--neutral-500);
}
input {
border: 1px solid var(--neutral-700);
background: var(--neutral-100);
}Open this in a browser and look at the page with the primary colour removed. If the layout still reads clearly (headings, body text, cards, and fields are distinguishable), the neutral scale is doing its job.
Exercise
A form input has border: 1px solid var(--neutral-300) on a --neutral-50 page, and users report they cannot see where the field ends. Which change fixes this, and why?
Show answer
Use a darker step for the border, such as --neutral-500 or --neutral-700. Step 300 is only about 80% lightness against a 97% background, so its contrast is far below the 3:1 that WCAG asks for on UI components. Keep step 300 for decorative dividers and card outlines.
Exercise
Why do the neutrals in this palette use hue 220 with 10% to 20% saturation instead of 0% saturation?
Show answer
The primary colour has hue 220. A small amount of the same hue in the neutrals ties the greys to the primary colour, so the whole page looks consistent instead of having cold or dead-looking greys beside the blue.