React Tutorials
React ES6
React Hooks
Sass is a pre-processor for CSS.
Sass files are applied to the server and send CSS to the browser.
If you use a create-react-app
for your project, you can easily install and use Sass for your React projects.
Install Sass using this command in your terminal:
>npm i sass
Now you are ready to add Sass files to your project!
Create a Sass file in the same way as you create CSS files, but Sass files have a .scss
file extension.
For Sass files you can use variables and other Sass functions:
Create a variable to define the color of the text:
$myColor: red;
h1 {
color: $myColor;
}
Import the Sass file in the same way as you import the CSS file:
import React from 'react';
import ReactDOM from 'react-dom';
import './my-sass.scss';
const Header = () => {
return (
<>
<h1>Hello Style!</h1>
<p>Add a little style!.</p>
</>
);
}
ReactDOM.render(<Header />, document.getElementById('root'));