What is the most efficient way to use CSS/SCSS in your project?
reactjs - How to use SCSS variables into my React components - Stack Overflow
Instances where you would use CSS vs SASS?
Depends on what you consider "better".
If I'm doing anything of significance, even a small project, I'll stick with Sass. Not because it's "better"; it all compiles to CSS anyway, but because it'll let me work the way I want with varibles and nesting, mixins, etc.
Sass (and LESS, Stylus, Css-Next, whatever's sexy now) are all just tools to get you down to css in a more manageable way. If they don't appeal to you, there's nothing wrong with pure CSS.
To answer your question though, for me the only reason I can think of to write in CSS rather than a preprocessor would be just for a quick demo of something small, like on codepen or jsfiddle.
More on reddit.comHow comfortable should you be with CSS before learning SASS?
Videos
I always have to scroll through the css file to the class I want to update or create. Is there an extension or a tool that would help me be more organized in terms of style? For example by clicking on the className in the project it pops up the stylesheet on the side for me to update easily?
From React 17
To access your scss variables into the react component, you need to do something like that
- Install
node-sassas a dependency or dev dependency - No need to do any config change in webpack
- import as a module <-- main point
variables.module.scss
$color: skyblue;
$primaryColor: red;
:export {
color: $color;
primary-color: $primaryColor;
}
App.js
import variables from '<YOUR_PATH>/variables.module.scss';
const App = () => {
console.log(variables);
}
If you don't want to use styled-component
then you can follow this link.
https://til.hashrocket.com/posts/sxbrscjuqu-share-scss-variables-with-javascript