Sub topic 9
Complementary, analogous, and triadic harmonies
This chapter assumes you know hue as an angle on the color wheel, and that you can read HSL values in CSS. A color harmony is a rule that picks several hues from the wheel so they look intentional together. Every harmony here is a rule about hue angles only. Saturation and value are tuned separately.
Harmonies are rotations
If hue is an angle from 0 to 360 degrees, a harmony is a set of rotations from a base hue. Pick a base, add fixed offsets, and wrap around at 360.
| Harmony | Offsets from base | Hues with base 210 |
|---|---|---|
| Complementary | 0, 180 | 210, 30 |
| Analogous | -30, 0, +30 | 180, 210, 240 |
| Triadic | 0, 120, 240 | 210, 330, 90 |
Complementary
Complementary hues sit opposite each other. They give the strongest hue contrast, so use them when you want one element to stand out, such as an orange button on a blue interface.
Placed side by side at full saturation, complements can seem to vibrate at the edge. Avoid putting them next to each other as large blocks. A common approach is to let the base hue cover most of the layout and use its complement in small amounts.
Analogous
Analogous hues are neighbors on the wheel, usually within 30 degrees of each other. They feel calm and unified because the colors share a family, such as blue, blue-cyan, and cyan.
The risk is flatness. With similar hues, nothing separates one element from the next, so you must create difference with value and saturation instead.
Triadic
Triadic hues are spaced 120 degrees apart, forming an equilateral triangle on the wheel. They look varied and lively while keeping a balance. Triads at full saturation can look loud, so make one hue dominant and lower the saturation or raise the lightness of the other two.
Computing harmonies in code
The same rotation works in code. This Python function returns hues for any set of offsets, using the modulo operator to wrap past 360.
def harmony(base_hue, offsets):
return [(base_hue + o) % 360 for o in offsets]
base = 210
print("complementary:", harmony(base, [0, 180]))
print("analogous:", harmony(base, [-30, 0, 30]))
print("triadic:", harmony(base, [0, 120, 240]))The output is [210, 30], [180, 210, 240], and [210, 330, 90]. Without the modulo, an offset of -30 on a base of 10 would give -20, which some tools reject.
In CSS, a custom property holds the base hue, and calc() applies the offset:
:root {
--hue: 210;
--base: hsl(var(--hue) 70% 45%);
--accent: hsl(calc(var(--hue) + 180) 80% 50%);
--triad-a: hsl(calc(var(--hue) + 120) 50% 55%);
--triad-b: hsl(calc(var(--hue) + 240) 50% 55%);
}Changing --hue moves the whole scheme at once.
Common errors
- Using every harmony color at full strength. Give one hue most of the area and use the others as accents.
- Relying on hue alone. Two harmonious hues with the same value can be hard to tell apart, which hurts legibility. Check value contrast as well.
- Treating angles as exact. Hue angles in HSL are a convenient model, not a perception-based one. Adjust by eye if a pair looks off.
Exercise
A base hue is 300 degrees. What are the triadic hues, and what is the complement?
Show answer
Triadic hues are 300, (300 + 120) % 360 = 60, and (300 + 240) % 360 = 180. The complement is (300 + 180) % 360 = 120.
Exercise
You build an analogous palette of hues 200, 215, and 230, and the interface looks flat. Which two properties should you vary to fix it, and why?
Show answer
Vary value and saturation. The hues are close, so they cannot separate elements. Lighter and darker values, and different saturation levels, create the contrast that hue offsets do not.