Building a UI color system (50–950 scales)
By Theo Lane (pen name; AI-assisted, hand-checked) ·
A brand palette of five colors is not enough to build an interface. You need hover and pressed states, subtle backgrounds, borders, disabled text, success and error colors, and a dark theme. A color system turns a few chosen colors into a predictable set of tokens that a whole team can use without guessing.
Layer one: scales
Start by expanding each base color into a scale. The convention popularized by Tailwind CSS uses eleven steps: 50, 100, 200 through 900, and 950. Step 50 is nearly white with a hint of the hue; 950 is nearly black. The middle steps carry the most chroma.
The key decision is how lightness is spaced. If every scale uses the same perceptual lightness targets — for example, step 500 at about 62% OKLCH lightness in every hue — then steps become interchangeable across hues. Blue-700 on blue-50 will have roughly the same contrast as green-700 on green-50. Palg’s color variations tool uses fixed OKLCH lightness targets and tapers chroma toward the ends, since very light and very dark colors cannot hold much saturation in sRGB.
You will typically want scales for:
- One or two brand hues (primary, secondary).
- A neutral — a gray with a slight hue cast that matches the brand (cool slate for a blue brand, warm stone for an orange one).
- Semantic hues: success (green), warning (amber), danger (red), info (blue).
Layer two: semantic tokens
Raw scale steps are not what components should reference. Instead, define semantic tokens that describe purpose:
--color-bg: var(--neutral-50);
--color-surface: #ffffff;
--color-border: var(--neutral-200);
--color-text: var(--neutral-900);
--color-text-muted: var(--neutral-600);
--color-primary: var(--brand-600);
--color-primary-hover: var(--brand-700);
--color-on-primary: #ffffff;
--color-danger: var(--red-600);
Now a redesign or a dark theme changes only the mapping, not every component. Designers and developers share one vocabulary: “use text-muted”, not “use #5b6577”.
Layer three: contrast rules
Write down which combinations are allowed. With evenly spaced lightness, rules generalize:
- Body text on steps 50–100 uses step 700 or darker (typically 4.5:1 or better).
- White text sits on step 600 or darker.
- Borders that identify inputs use step 400–500 against white for 3:1 (WCAG 1.4.11).
- Muted text never goes lighter than step 600 on white.
Verify each rule with real numbers in the contrast checker — scales differ slightly by hue, and yellows in particular need darker steps to pass.
Dark mode
Dark mode is not inversion. In a dark theme, surfaces are dark neutrals (steps 900–950), text is light (50–200), and brand colors shift to lighter steps (often 400 instead of 600) so they keep contrast against dark backgrounds without glowing. Elevated surfaces become slightly lighter rather than casting shadows. Because the semantic layer is separate, you only remap tokens:
[data-theme="dark"] {
--color-bg: var(--neutral-950);
--color-surface: var(--neutral-900);
--color-text: var(--neutral-100);
--color-primary: var(--brand-400);
--color-on-primary: var(--neutral-950);
}
Reduce chroma slightly for large dark areas; saturated dark backgrounds are tiring.
States
Hover, pressed, focus, selected and disabled each need a defined color. A simple pattern: hover moves one step darker (600 → 700), pressed two steps, selected uses a tinted background (step 50 or 100) with a step-700 label. Focus rings need 3:1 against both the component and the page; a 2px ring in brand-600 with a 2px white gap works on most backgrounds.
Charts and data
Data visualization needs its own small set: a categorical palette of five to eight colors that differ in lightness as well as hue, and sequential and diverging ramps. Test categorical palettes with the color blindness simulator, and see our CVD guide for patterns.
Exporting and maintaining
Keep the source of truth in code. Palg exports Tailwind config objects, CSS custom properties, SCSS maps and JSON; design tools can import ASE files or, in Figma, styles and variables via our plugin. Version your tokens like any other dependency, and document the contrast rules next to them. When the brand changes, regenerate scales, re-run the contrast checks, and ship.
Start small
You do not need fifty tokens on day one. A neutral scale, one brand scale, four semantic colors and a dozen semantic tokens will cover most products. Add more only when a real component needs it — that restraint is what keeps a color system usable.