Skip to content
Guest
Tailwind CSS · Course Syllabus Show lessons
Design Systems · 8 min read · Beginner

Color Tokens, Surfaces & Dark Mode Systems

Build effortless light and dark themes using semantic CSS variables and Tailwind's `dark:` modifier.

What you'll learn

  • Separate background, elevated card, border, and muted text layers
  • Guarantee WCAG AA 4.5:1 contrast in both light and dark themes
  • Avoid pure `#000000` dark surfaces — deep slate (`#0b0f14`) reads cleaner

Overview

Build effortless light and dark themes using semantic CSS variables and Tailwind’s dark: modifier.

Code Example

:root {
  --bg: #ffffff;
  --bg-elevated: #f8fafc;
  --text: #0f172a;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f14;
    --bg-elevated: #141b24;
    --text: #f8fafc;
  }
}

Key Takeaways

  • Separate background, elevated card, border, and muted text layers
  • Guarantee WCAG AA 4.5:1 contrast in both light and dark themes
  • Avoid pure #000000 dark surfaces — deep slate (#0b0f14) reads cleaner

Quick Check

Check Your Understanding

Score: 0 / 1

1. Why are semantic tokens like `--bg-elevated` and `--text-muted` easier to maintain than raw colors?

Study Workspace

Finished this lesson?

Your progress is saved locally in your browser, no account needed.

Search courses, lessons, and references

Type to search across all courses, lessons, and quick references.

Press Esc to close Powered by Pagefind