MA6: Touch, gestures and accessibility

Lesson 4 of 5 · reading 15–25 minutes; practice and project time is on the module page

Text, colour and dark mode

🎯You'll be able to

Support large text, choose colours with enough contrast, and follow the phone's dark mode setting with theme tokens.

🏠The everyday picture

A shop sign has to be readable in midday sun and at night under a street lamp. The best signs use strong contrast and change their lighting for the evening.

📘What it really is

📝A worked example

Input: KhetNote's starter uses #A0A8A0 for secondary text on white, and one palette for both modes.

Steps:

  1. Measure: about 2.4:1, well below 4.5:1. Choose a darker grey (#4A5548, about 7.8:1).
  2. Add THEMES.light and THEMES.dark with the same token names, checking each text colour on its backgrounds.
  3. Make useTheme() return the palette for useColorScheme(), and use it in every component.

Expected output: readable text in both modes, which changes when the phone's setting changes.

🌍Where it's used

📝Case scenario

A delivery app's dark mode kept the light palette's dark-grey text on a near-black background. Drivers at night couldn't read the address. A separate dark palette, checked for contrast, fixed it.

🖱️Try it

Calculate (with any contrast checker) the contrast of KhetNote's starter textMuted on white and of your replacement. Success: your choice is at least 4.5:1.

⚠️Common mistakes

🛠️For your project

Project 2's tests 7 and 8 check dark mode and contrast for text, muted text, button text and errors in both palettes.

✅Quick check

What contrast does normal text need against its background?

Show the answer

At least 4.5:1.

Why use colour tokens instead of hard-coded colours?

Show the answer

So both palettes, and any change, reach every screen.

← PreviousScreen readers
ProLearners Assist