Typography, Color Spaces & Vector Craft

Building Accessible Light and Dark Color Palettes with Luminance Ratios

A caption can pass on a white canvas and fail when it moves into a tinted panel. Build light and dark palettes by measuring each ink against every surface it can touch. This guide shows how to calculate those ratios, set three legible ink levels, and give quiet dividers and functional borders different jobs.

Contrast at the panel surface 01 Primary ink 02 Muted ink 03 Control edge Light panel · #F8FAFC Dark panel · #1E293B #141923 · 16.82:1 #F8FAFC · 13.98:1 #475569 · 7.24:1 #94A3B8 · 5.71:1 #737D8C · 3.98:1 #64748B · 3.07:1
Read across each row to compare the same role on both panel surfaces. Each ratio uses the dot or outlined square and its own panel fill, with the rightmost panel showing where dark-mode muted ink and the control edge have the least margin.

Map the surfaces before choosing ink

Start with one working screen that has body copy on the canvas, a caption inside a panel, and an input with a visible boundary. Record the actual fills behind those elements in both themes. For this guide, the light canvas is #FFFFFF and its panel is #F8FAFC. The dark canvas is #141923 and its panel is #1E293B. A caption that appears on both surfaces has two pairs per theme, even when the component shares one ink token.

Use WCAG 2.2 AA contrast minimums of 4.5:1 for ordinary text and 3:1 for large text. Large text starts at 18 pt regular or 14 pt bold, equivalent to 24 CSS px or about 18.67 CSS px respectively. Treat a 14 px caption or input label as ordinary text at any weight. A separate 3:1 rule covers visual information needed to identify applicable controls, their states, and meaningful graphics against adjacent colors. W3C text contrast guidance and W3C non-text contrast guidance.

Give the pair a name you can find in a bug report, such as “muted ink on dark panel.” Record the component and state alongside it. This catches a common omission when a card gains a selected background after the palette review and inherits the same caption ink.

Calculate the ratio from sRGB values

Split each opaque hex color into three byte values and divide each by 255. On each normalized channel c, use c / 12.92 when c is at or below 0.04045. Above that cutoff, use ((c + 0.055) / 1.055)^2.4, where the caret denotes exponentiation. Multiply the resulting linear red, green, and blue by 0.2126, 0.7152, and 0.0722 respectively, then sum them to obtain relative luminance L. Divide the lighter color’s L plus 0.05 by the darker color’s L plus 0.05. W3C relative luminance definition.

For light muted ink #475569, the bytes are 71, 85, and 105. Their normalized values are approximately 0.27843, 0.33333, and 0.41176. All three use the exponent branch, producing approximately 0.06301, 0.09084, and 0.14126. The weighted sum is 0.088565. The light panel has luminance 0.953559, so (0.953559 + 0.05) / (0.088565 + 0.05) gives about 7.24:1. The same ink reaches 7.58:1 on white. Check your spreadsheet with black against white, which yields 21:1, and a color against itself, which yields 1:1.

Keep full precision through the pass decision. For example, #777777 on white yields about 4.478:1. A display rounded to one decimal shows 4.5:1, but the pair fails for ordinary text. This also matters when matching a design tool’s rounded readout to a build check.

Build an ink hierarchy around the tightest surface

Assign primary ink to body copy and dense readings, secondary ink to supporting labels, and muted ink to captions and metadata that still need to be read. Use placement, spacing, and weight to reinforce those roles. On the light panel, the three example inks step down from 16.82:1 to 9.90:1 to 7.24:1. On the dark panel, they step down from 13.98:1 to 11.87:1 to 5.71:1. Both themes preserve the same order while allowing different gaps between the steps.

Solve for a candidate luminance before tuning hue. For darker ink against a light surface with luminance S, the maximum ink luminance is (S + 0.05) / ratio − 0.05. For lighter ink on a dark surface, the minimum is ratio × (S + 0.05) − 0.05. At 4.5:1, the light panel caps darker ink at about 0.17301. The dark panel needs lighter ink at about 0.27299 or higher. Candidate #7C8CA0 has luminance 0.25579 and reaches 5.13:1 on the dark canvas but only 4.26:1 on the panel. Raising it to #94A3B8 gives a useful margin for small metadata.

When tuning a tint, export the final eight-bit sRGB hex and calculate again. Changing hue also changes luminance, particularly when the green channel moves. Review the ink steps at their actual font sizes. A numerical gap can be hard to distinguish if two adjacent labels share weight, size, and alignment.

Give quiet separators and control edges distinct tokens

A decorative separator can sit close to its background when spacing or headings already communicate the grouping. The same faint line becomes a problem if it is the only cue that locates an empty text field. Keep a decorative separator token and a control edge token. Reserve the stronger edge for places where the boundary supplies information the user needs.

For an input with a white fill sitting on the light panel, measure the stroke against both adjacent fills. The example light edge, #737D8C, reaches 4.17:1 against white and 3.98:1 against the panel. In dark mode, #64748B reaches 3.70:1 against the canvas and 3.07:1 against the panel. That second result has little headroom. If the border looks weak at its shipped width, test #78879A, which reaches 3.99:1 against the dark panel, or use a wider stroke. Align the stroke to the pixel grid where the layout permits and inspect it at normal viewing size.

Example token pairs for light and dark canvases and panels
RoleLight tokenLight canvasLight panelDark tokenDark canvasDark panel
Primary ink#14192317.60:116.82:1#F8FAFC16.82:113.98:1
Secondary ink#33415510.35:19.90:1#E2E8F014.28:111.87:1
Muted ink#4755697.58:17.24:1#94A3B86.86:15.71:1
Decorative separator#CBD5E11.48:11.42:1#3341551.70:11.41:1
Control edge#737D8C4.17:13.98:1#64748B3.70:13.07:1

Values are rounded for reference. The same dark edge that passes as a boundary on the panel fails as ordinary text there. Keep input hints on an ink token even when they sit next to the border and seem visually related.

Verify the palette in the shipped layout

Open the component in both themes and inspect the resolved foreground and background in browser developer tools. Follow the background through transparent ancestors until you find the visible surface. For translucent ink, resolve its composited color over each backdrop before calculating luminance. Over a gradient, check the weakest local pairing within the area the glyphs occupy, including any shift caused by a different line break. If that area keeps moving or the backdrop is unpredictable, place an opaque backing behind the text.

As a quick compositing check, place 50% opaque black text on solid white in an ordinary sRGB layer. The resolved channels are halfway between black and white, giving a luminance of about 0.214 and a ratio of about 3.98:1. A contrast picker that reads the black token alone would report 21:1. Inspect opacity on the parent as well as the text layer, especially when a card fades during a state change. For that combination, an opaque ink token makes the pass decision easier to reproduce.

Read the smallest caption at normal zoom and check the layout again at 200% zoom. Enlarging the page can move text onto a different part of a gradient or into a panel with a different fill. Use the intended foreground and background colors for the ratio. Thin strokes and antialiased text deserve a separate visual check because their blended edge pixels can make an otherwise passing pair look weak. If a failure appears only on hover or selection, capture the state with the exact pair before adjusting the token.

  • Record the resolved sRGB foreground and immediate background for every ink role on each allowed canvas and panel in both themes.
  • Compare each full-precision ratio with its threshold, including captions, helper text, input labels, and any large text exception.
  • Check required control boundaries and state cues against the adjacent colors they must stand out from. Verify keyboard focus on the surfaces that surround it.
  • Walk through hover, focus, selected, and error states. Repeat pair measurements whenever a state changes the foreground, fill, or opacity.
  • Recheck the weakest pair after a token edit and save the component, theme, state, two colors, and computed ratio with the review.