This is working example of theme switcher in ReactJS by using Context API Hook and CSS Variables.
/components
: For all reusable components
/pages
: For pages
/components/context.js
: This file has the context of the theme
App.js
: App.js has the provider of the theme and handling the logic of toggling the theme
assets/style/style.css
: CSS Variables for the theme
-
Download or clone the repo
-
run
npm install
-
run
npm start
-
Go to your localhost