I’m working on a React app for my college project (using React + Vite) and I recently tried changing my theme colors defined in :root. However, the new values are not reflected across my site — only some places update, while most elements still use the old theme.
Here’s my setup:
index.css
/* old theme */
/* :root {
--app-primary: #BA3111;
--app-dark: #1E1F29;
--app-light: #F5F0E5;
--app-warm-grey: #6D6A6A;
--app-sage-green: #8FA998;
--app-yellow: #E1B530;
--app-light-transparent: #F5F0E5e1;
--app-primary-transparent: #BA311110;
} */
/* new theme */
:root {
--app-primary: #007bff;
--app-dark: #f2f2f2;
--app-light: #1e1f29;
--app-warm-grey: #6D6A6A;
--app-sage-green: #8FA998;
--app-yellow: #E1B530;
--app-light-transparent: #1e1f29e1;
--app-primary-transparent: #007bff10;
}
@font-face {
font-family: 'Nunito';
src: url('assets/fonts/Nunito/Nunito-VariableFont_wght.ttf');
}
Header.module.css
/* background color of header got changed successfully */
.header {
position: sticky;
top: 0;
left: 0;
width: -webkit-fill-available;
height: 8vh;
justify-content: space-between;
padding-inline: 50px;
background: var(--app-light-transparent);
z-index: 20;
box-shadow: 0 0 0.2rem rgba(0, 0, 0, 0.1);
backdrop-filter: blur(5px);
}
/* color of header title and other menu options are still old */
.header h1 {
color: var(--app-primary);
font-size: clamp(20px, 1.7rem, 60px);
}
Also across the rest of the site, the old theme colors are still being applied. I already tried Empty Cache and Hard Reload, but not working.
Why are my CSS variables from :root not updating everywhere in my React + Vite project, and how can I ensure the new theme colors are applied globally?