- Toggle between pink and blue themes
- Minimal design
The main logic happens because of the changeTheme() function which switches themes.
- CSS has predefined rules for each theme
- Function check if the
bodyelement already containblueclass, if yes, it removesblueclass from thebodyto execute CSS rules for the pink theme. And addblueclass in opposite case. - Then it executes two state management functions:
setText- changes the displayed text to match the current theme. Passed as a prop toButtoncomponent.setColor- changes the SVG heart icon color.
- Node.js (install from https://nodejs.org/)
node --version #Should be v18+- npm (installed with node)
npm --version #Should be v9+- Clone or download the repo:
git clone https://github.com/Flint15/theme-change-react.git
cd theme-change-react- Install dependencies
npm install- Start the project
npm run dev- React
- TypeScript
- Vite
