The Sooq apps have colours that carry meaning: red for errors and sales, green for success, amber for warnings, blue for information. I picked them against a white background and they looked great. Then I turned on dark mode.
The number that matters
Contrast between text and background is measured as a ratio. Normal text needs at least 4.5 to 1; graphics such as icons need 3 to 1.
Measured against the dark card, my red was 2.65 and my blue 2.46 — below even what an icon needs, let alone text.
Why that is dangerous
Red is there for one reason: to be the thing the eye catches first. An error message nobody can read is not a cosmetic problem; it is important information lost. A red you cannot read is worse than no red at all, because it lets you believe you told the user when you did not.
The fix: two sets
One colour cannot work on both backgrounds, so there are now two sets, one per mode. For each colour I changed only the lightness, raising or lowering it until it measured, so it still reads as the same colour. The measurement is written next to each value in the code:
- Dark-mode red: 2.65 → 4.59.
- Blue: 2.46 → 4.67.
- Amber on white: 3.93 → 4.59.
A single function picks the right version for the current mode, so no screen has to remember.
A deliberate exception
The rating star is a graphic, not text, so it is held to 3 to 1. Pushing it to 4.5 turned the gold brown, so it stays at 3 — the right rule for it is the graphics rule.
What I learned
- Do not pick colours by eye alone. Measure them.
- Test every colour on both backgrounds.
- Write the measurement next to the colour, so nobody "fixes" it later and breaks it.