Styling React Using Sass
Styling React Using Sass
❮ PreviousNext ❯
What is Sass
Sass files are executed on the server and sends CSS to the browser.
If you use the create-react-app in your project, you can easily install and use Sass in your React
projects.
npm i sass
Create a Sass file the same way as you create CSS files, but Sass files have the file extension .scss
In Sass files you can use variables and other Sass functions:
my-sass.scss:
$myColor: red;
h1 {
color: $myColor;
Import the Sass file the same way as you imported a CSS file:
Example
index.js:
import './my-sass.scss';
return (
<>
<h1>Hello Style!</h1>
</>
);
root.render(<Header />);