Sub topic 7
Expanding each colour into a scale of shades
This chapter assumes you can read HSL values (hue, saturation, lightness) and that you have picked a primary colour, a set of neutrals, and an accent. A single value such as --primary-500 is not enough for a real interface. You also need a lighter tint for a hover background, a darker shade for link text, and a mid-tone for buttons. A colour scale is an ordered set of steps that all share one hue.
Why one value is not enough
A page needs the same colour in several jobs:
- A pale tint for a selected row or an info banner background.
- The base colour for buttons and icons.
- A dark shade for text on a light background and for pressed states.
If you improvise these by eye, the hues drift and the interface looks inconsistent. A scale fixes the hue and varies the other values in a predictable way.
Tints, shades, and the numbering convention
A tint is a colour mixed toward white. A shade is a colour mixed toward black. In a scale, both are steps along the lightness axis. Most design systems number steps from 50 or 100 (lightest) to 900 (darkest), with 500 as the base colour. The numbers are labels only. They give you room to insert a step later, such as --primary-600, without renaming the others.
Building a scale in HSL
HSL makes this easy because you edit one number. Keep the hue fixed and choose lightness values that are spaced out, not evenly stepped.
| Step | Lightness | Typical use |
|---|---|---|
| 50 | 96% | Page tint, subtle backgrounds |
| 100 | 92% | Hover backgrounds |
| 200 | 84% | Borders on tinted areas |
| 400 | 62% | Icons, decorative fills |
| 500 | 50% | Buttons, base colour |
| 600 | 42% | Button hover |
| 700 | 34% | Links, text on light |
| 900 | 18% | Headings on tinted areas |
You do not need every number. Nine steps are common, but five or six cover most small sites.
Adjusting saturation at the ends
A fixed saturation looks wrong at the extremes. At 96% lightness, a colour with 80% saturation looks faintly neon. Very dark steps with high saturation look muddy. Reduce saturation a little as lightness moves away from the middle. In the earlier palette, --primary-100 uses 80% saturation, and you can lower it further for the lightest steps.
:root {
--primary-50: hsl(220 70% 97%);
--primary-100: hsl(220 75% 94%);
--primary-200: hsl(220 78% 86%);
--primary-400: hsl(220 80% 65%);
--primary-500: hsl(220 80% 50%);
--primary-600: hsl(220 80% 42%);
--primary-700: hsl(220 80% 34%);
--primary-900: hsl(220 70% 18%);
}Only the second and third numbers change from line to line. The hue stays at 220, so every step reads as the same colour.
Generating a scale with a script
Writing these by hand for three colours is tedious. A short script makes the rule explicit and repeatable.
const steps = {
50: [70, 97],
100: [75, 94],
200: [78, 86],
400: [80, 65],
500: [80, 50],
600: [80, 42],
700: [80, 34],
900: [70, 18],
};
function buildScale(name, hue) {
return Object.entries(steps)
.map(([step, [s, l]]) => ` --${name}-${step}: hsl(${hue} ${s}% ${l}%);`)
.join("\n");
}
console.log(":root {\n" + buildScale("primary", 220) + "\n}");Run it with Node and paste the output into your stylesheet. To make an accent scale, call buildScale("accent", 35). Neutrals use the same idea, but with low saturation, such as 12% to 20%, and the same hue as the primary so greys look related to it.
Common errors
- Changing hue between steps. Darker blues pushed toward purple look accidental. Keep the hue fixed unless you shift it by a few degrees on purpose.
- Too many steps. Unused steps are clutter. Add steps when a component needs one.
- Evenly spaced lightness. The lightest and darkest steps are used less often, so the middle of the scale needs more resolution.
- Treating the scale as the contrast check. A step's number says nothing about whether text on it is readable. The next chapter covers that test.
Exercise
You have --accent-500: hsl(35 95% 50%). Write the HSL values for a very light tint (step 50) and a dark shade (step 700) of this accent, and explain what you kept the same and what you changed.
Show answer
For example, --accent-50: hsl(35 90% 96%) and --accent-700: hsl(35 90% 30%). The hue (35) stays the same so both steps read as the same orange. Lightness changes substantially (96% and 30%). Saturation drops slightly from 95% to avoid a neon look on the light tint and a muddy look on the dark shade.