SpinTheMic
Pro

Interview practice question

Implementing a dark mode toggle

Frontend Engineering · React · Intermediate

How would you implement a dark mode toggle in a React app that remembers the user's choice?

What a strong answer covers

Your AI report card counts how many of these ideas you cover.

  • CSS variables for theme colours.
  • Theme state in context; data attribute on html.
  • Persist in localStorage; respect prefers-color-scheme.
  • Avoid flash with early inline script.
  • Accessible toggle.
Practise this topic

Start without signing up. Sign in free to get an AI report card on your answer.

See all topics