A simple mistake that can screw up your light/dark theme (and how to fix it)

Kevin Powell on YouTubeWatch on YouTube

SaveMark complete

Sign in to save videos and track what you’ve finished.

IntermediateUI5 min

About this video

Shows how a light/dark theme set by the system preference can conflict with a user's manual color-scheme choice, and walks through a fix. Aimed at people building web interfaces with CSS.

What you’ll learn

  • Respect the system color-scheme preference with prefers-color-scheme
  • Detect when a manual theme choice conflicts with system settings
  • Apply a fix that keeps a user-selected light or dark theme