Change the theme
Justified’s default theme is neutral on purpose, so your brand can replace it. The names stay the same; only the values change.
Where the colours live
Section titled “Where the colours live”After you add the theme, your main CSS file has two blocks: :root for the light theme and .dark for the dark one. Change the hex values there. Components read the variables, so they follow at once.
Change other tokens the same way: --radius for corners, --font-family-sans for the typeface, --layout-max-width for how wide content gets.
If you installed the theme from npm instead, the values live in the package. Write your own :root and .dark blocks after its imports and set only the variables you change; they win because they come later.
Keep the contrast
Section titled “Keep the contrast”Every colour is part of a pair: a text colour and the surface it sits on, or a border and the page. When you change one side, check the pair again, in both themes.
| Pair | Used for | Needs |
|---|---|---|
--foreground on --background |
Body text | 4.5:1 |
--muted-foreground on --background and on --muted |
Secondary text | 4.5:1 |
--primary-foreground on --primary |
Primary button label | 4.5:1 |
--primary on --background |
Links | 4.5:1 |
--destructive, --success, --warning, --info on --background |
Status messages | 4.5:1 |
Each status colour’s -foreground on the colour |
Text on status fills | 4.5:1 |
--input on --background |
Input borders | 3:1 |
--ring on --background |
Focus ring | 3:1 |
Text needs 4.5:1 (WCAG 2.2, 1.4.3 Contrast (Minimum)). Borders that show where a field is, and the focus ring, need 3:1 against the page (WCAG 2.2, 1.4.11 Non-text Contrast). Any contrast checker that takes two hex values will tell you the ratio.
The default theme and its measured ratios are in Storybook under Foundations, Colour.
Colour is never the only signal
Section titled “Colour is never the only signal”Whatever colours you choose, an error is also shown with an icon and words, and a link is also underlined or otherwise marked. Justified’s components already do this; keep it when you change them.
Justified is an independent project. It is not affiliated with, sponsored or endorsed by the organisations whose guidance it cites. Read the full statement.
Apple is a trademark of Apple Inc., registered in the U.S. and other countries and regions.