In my React project, I have integrated multiple variables that I would like to be able to access from other CSS files in order to maintain a unified codebase for specific UI configurations such as colors and buttons.
However, I am uncertain whether these variables should be declared within body{}
or :root{}
.
Index.css
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
margin: 0;
min-width: 100%;
min-height: 100%;
margin: 0;
padding: 0;
background-repeat: no-repeat;
background: var(--GradientLighterBlue);
--LightBlue:rgb(1,147,207);
--MediumBlue: rgb(1, 126, 207);
--DarkBlue: rgb(7, 101, 195);
--GradientLighterBlue: linear-gradient(0deg, rgba(1,126,207,1) 0%, rgba(1,147,207,1) 100%);
--GradientDarkerBlue: linear-gradient(0deg, rgba(7,101,195,1) 0%, rgba(0,72,144,1) 100%);
--LightYellow: rgb(252,177,52);
--MediumYellow: rgb(194,136,41);
--GradientYellow: linear-gradient(0deg, rgba(194,136,41,1) 0%, rgba(252,177,52,1) 100%);
}
How can I use references such as var(--LightYellow)
in a file like home.css
?