Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add SCSS styles to a React project?

Tags:

I'm just starting to learn React (have some JavaScript knowledge, as I'm learning tis as well) and building my first project. I would like to know how to add styles to my first React project, using CSS/SCSS as I have some knowledge and understanding from my html, CSS/SCSS learning projects.

How do you add SCSS to your React Project?

like image 779
Will Avatar asked May 02 '21 02:05

Will


People also ask

Can I use SCSS in react?

Can I use Sass? If you use the create-react-app in your project, you can easily install and use Sass in your React projects. Now you are ready to include Sass files in your project!

Can we use both CSS and SCSS in react?

Introduction: We can use SASS in React using a package called node-sass. Using node-sass we can just create sass files and use them as the normal CSS files in our React application and node-sass will take care of compiling sass files. Modules: To compile sass code, node-sass can be used.


1 Answers

If using create-react-app then:

1)First install sass dependency using npm:

npm install sass

2)Import your sass file to your componentName.js file

import '../scss/FileName.scss';

like image 114
restricted-beam Avatar answered Sep 21 '22 10:09

restricted-beam