Question · JavaScript and React course · Module 14: Advanced Styling

CSS Variables in React

How do you switch themes (dark/light) in React using CSS Variables?

Answer options

  • We change the object with CSS variables in the style attribute of the wrapping element
  • We import a separate CSS file for each theme
  • We use JavaScript to directly modify each DOM element
  • We restart the React application with a different config file

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