Question · Next.js course · Module 3: Styling and Visual Optimization

Detecting system theme preference

Which expression did the lesson use to detect the system dark-theme preference?

Answer options

  • window.matchMedia('(prefers-color-scheme: dark)')
  • window.localStorage.dark
  • document.theme === 'dark'
  • navigator.colorScheme()

You can check the correct answer by solving this task in the CodeWorlds game.