Bea’s Hawthorn Seed Library catalogue now feels like one of her seed packets, and you’ve finished Color, Themes and Motion. You can now build light and dark themes from tokens with modern color, check that every text and interface color meets WCAG AA contrast in both, and add motion and page transitions that respect people’s settings.
Before and After
- A palette in
oklch(): Bea’s three packet colors became tokens inoklch(), and the green scale steps only in lightness. Tints mix from the brand green withcolor-mix(). The hover shade on the Borrow seeds button is a relative color derived from the terracotta. It sits inside@supports, after a plain value. - Two themes: Each color role is declared once with
light-dark(), so the catalogue follows the visitor’s system setting or the System, Light and Dark switch. The “Returns week” banner stays dark in both themes. - Contrast: Three seed type tags at one lightness looked equally readable, but the bean measured 4.42:1 in the light theme, under the 4.5:1 that normal-size text needs. Equal lightness isn’t equal contrast. Now every pair passes in both themes. The bean tag clears 4.5:1 (4.81:1 light, 7.61:1 dark), and the focus ring clears the 3:1 that interface parts need (3.81:1 and 11.07:1).
- People’s settings: Under reduced motion, the “Returns week” banner and the filter panel fade instead of sliding. The “New this week” badge is feedback worth keeping, so it still pulses, only calmer. In forced colors, the buttons and the focus ring keep their edges.
- Page transitions: A seed’s photo grows from its card into its page. Where view transitions aren’t supported, the link still works, with a plain cut.
Things to Remember
- Step a palette in
oklch()lightness, and name the color space incolor-mix(). - Put a plain value first, and relative colors inside
@supports. - Declare each role once with
light-dark(). - Measure every pair in both themes: equal lightness isn’t equal contrast.
- Under reduced motion, swap movement for a fade, and keep the feedback.
- Draw edges and focus rings with transparent borders and outlines, never only
box-shadow, because forced colors paints them in and removes box shadows.