Currently brewing — dede is in beta: a first set of components, with more to come. The API may still change.

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.

successerrorwarninginfo

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.

successerrorwarninginfo

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.

CheckLightDarkNeeds
text primary15.60:114.98:14.5:1
text secondary8.66:18.29:14.5:1
text tertiary5.42:16.23:14.5:1
primary to secondary text(lightness apart)18195
secondary to tertiary text(lightness apart)1185
icon primary13.88:114.21:13:1
icon secondary7.40:18.29:13:1
icon tertiary3.55:14.37:13:1
control border3.55:16.46:13:1
border strong2.03:12.08:12:1
raised against page1.04:11.14:11.1:1
sunken against page1.11:11.10:11.1:1
subtle border on raised1.31:11.26:11.15:1
success on every surface and its tint4.54:18.55:14.5:1
success strong on every surface5.24:19.59:13:1
success border on its tint2.16:12.15:12:1
error on every surface and its tint4.54:15.75:14.5:1
error strong on every surface5.29:16.40:13:1
error border on its tint2.17:12.16:12:1
warning on every surface and its tint4.53:18.97:14.5:1
warning strong on every surface5.21:110.04:13:1
warning border on its tint2.15:12.16:12:1
info on every surface and its tint4.53:15.78:14.5:1
info strong on every surface5.24:16.99:13:1
info border on its tint2.17:12.16:12:1