Base color
Your base color is the color of your page. dede makes every other color from it. This guide explains what makes a good one, and you can try a color at the end.
When you have chosen, set it in your CSS: Set your own color has the steps. Every color dede makes from it is on Color.
Choosing a base color
Any color works, but some leave more room for text than others. Lightness here runs from 0 (black) to 100 (white).
A light or a dark color works best
Body text needs a contrast of at least 4.5:1 with the page. On a light page (lightness about 65 or more) or a dark one (about 35 or less), there is room for three levels of text that look clearly different, with tertiary still at 4.5:1.
Primary text is lightness 20 on a light page. On a light page darker than about 75, that leaves too little room, so dede makes primary text darker, down to 10. It goes only as far as it needs to keep the three levels at least 5 apart.
A mid color holds one level of text
Between those, even black or white text reaches only about 5:1 to 9:1. There is room for one level, so secondary and tertiary text look the same as primary. Right in the middle, around lightness 55 to 60, even primary text falls below 4.5:1.
A mid color still works, with that limit. It suits a band with a heading and a line of text, or a fill such as a button or a badge, more than a whole page of reading. The dede-color command makes every color from it, and prints a warning that says which levels fall short.
Light or dark decides which mode is yours
dede decides by contrast: if its dark text reads at least as well on your color as its light text, your color is light; if not, it’s dark.
A light color is your light page, exactly as you wrote it, and dede makes the dark mode. Its dark page is always lightness 20, as dark as dede’s own, with a little of your color’s tint. A dark color is your dark page, and dede makes the light mode. So if you want your dark mode in your exact color, start from a dark color. A page with no data-mode uses your color’s mode, so a site with only a dark mode needs nothing else. Your color doesn’t need to be a round number: dede’s own, #fafafa, is lightness 98.5.
White and black pages
Nothing is lighter than white, so on a white page a card can’t be lighter than the page. It stands out by its border and shadow instead. On a black page, a well can’t be darker than the page, so it relies on its border too.
Why the colors are checked
Every color is tested against whatever it sits on, and against anything that sits on it. Text needs 4.5:1. Icons and the edge of a control need 3:1. A status message’s border needs 2:1 against its tint. The checks below show each one for the color you try.
dede tests every color it makes, from its own base color or from yours. When a color falls short, the dede-color command says which one and by how much. A color you set by hand in your own CSS isn’t tested.
Try a color
Type a hex color, pick one, or start from one of these. The panels show what dede makes from it, in both modes.
Every check passes.
Light
Lightness 98.5: your color
Primary text, for headings and anything that must stand out.
Secondary text, for body text.
Tertiary text, for a date or a hint.
On a raised card
On a sunken surface: code, a stage, a track.
Borders: subtle, default, strong
Dark
Lightness 20: made by dede
Primary text, for headings and anything that must stand out.
Secondary text, for body text.
Tertiary text, for a date or a hint.
On a raised card
On a sunken surface: code, a stage, a track.
Borders: subtle, default, strong
The ramp
--color-base-0 to --color-base-100, in your color’s own mode. There is a step at every whole number. The number is the lightness. The strip shows 20 of them.
The checks
Each color against what it sits on, and the contrast it needs.
| Check | Light | Dark | Needs |
|---|---|---|---|
| text primary | 15.60:1 | 14.98:1 | 4.5:1 |
| text secondary | 8.66:1 | 8.29:1 | 4.5:1 |
| text tertiary | 5.42:1 | 6.23:1 | 4.5:1 |
| primary to secondary text(lightness apart) | 18 | 19 | 5 |
| secondary to tertiary text(lightness apart) | 11 | 8 | 5 |
| icon primary | 13.88:1 | 14.21:1 | 3:1 |
| icon secondary | 7.40:1 | 8.29:1 | 3:1 |
| icon tertiary | 3.55:1 | 4.37:1 | 3:1 |
| control border | 3.55:1 | 6.46:1 | 3:1 |
| border strong | 2.03:1 | 2.08:1 | 2:1 |
| raised against page | 1.04:1 | 1.14:1 | 1.1:1 |
| sunken against page | 1.11:1 | 1.10:1 | 1.1:1 |
| subtle border on raised | 1.31:1 | 1.26:1 | 1.15:1 |
| success on every surface and its tint | 4.54:1 | 8.55:1 | 4.5:1 |
| success strong on every surface | 5.24:1 | 9.59:1 | 3:1 |
| success border on its tint | 2.16:1 | 2.15:1 | 2:1 |
| error on every surface and its tint | 4.54:1 | 5.75:1 | 4.5:1 |
| error strong on every surface | 5.29:1 | 6.40:1 | 3:1 |
| error border on its tint | 2.17:1 | 2.16:1 | 2:1 |
| warning on every surface and its tint | 4.53:1 | 8.97:1 | 4.5:1 |
| warning strong on every surface | 5.21:1 | 10.04:1 | 3:1 |
| warning border on its tint | 2.15:1 | 2.16:1 | 2:1 |
| info on every surface and its tint | 4.53:1 | 5.78:1 | 4.5:1 |
| info strong on every surface | 5.24:1 | 6.99:1 | 3:1 |
| info border on its tint | 2.17:1 | 2.16:1 | 2:1 |