Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Color, Themes and Motion (Summary)

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 in oklch(), and the green scale steps only in lightness. Tints mix from the brand green with color-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 in color-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.

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

00:00 Bea’s catalogue now feels like one of her seed packets, and you’ve finished the course. 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.

00:21 Bea’s packet colors became tokens in oklch(), and the green scale steps only in lightness.

00:30 Tints mix from the brand green. The hover shade is derived from the terracotta.

00:37 Each role is declared once with light-dark(), so the catalogue follows the system or the switch. The Returns week banner stays dark.

00:47 Then you measured. Three tags at one lightness looked equally readable, but the bean measured 4.42 to 1, under the 4.5 that normal-size text needs. Equal lightness isn’t equal contrast.

01:02 Now every pair passes in both themes. The bean tag clears 4.5, and the focus ring clears the 3 to 1 that interface parts need. Under reduced motion, the banner and filter panel fade instead of sliding.

01:17 The New this week badge is feedback worth keeping, so it still pulses, only calmer. In forced colors, buttons and the focus ring keep their edges. And a seed’s photo grows from its card into its page.

01:32 Where that isn’t supported, the link still works, with a plain cut.

01:37 Remember these. Step a palette in oklch() lightness, and name the space when you mix. Put relative colors in @supports, after a plain value.

01:48 Use light-dark() to declare each role once. Measure every pair in both themes. Swap movement for a fade, and keep the feedback. And draw edges with transparent borders and outlines, because forced colors paints them in and removes box shadows.

02:06 Compare your site with the finished one in the course’s download. This is course 3 of 5 on the Modern CSS and Accessible Interfaces path, so carry on with its next course.

02:18 Thanks for following along.

Become a Member to join the conversation.