If using create-react-app then:

1)First install sass dependency using npm:

npm install sass --save-dev

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

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

Answer from restricted-beam on Stack Overflow
🌐
Create React App
create-react-app.dev › docs › adding-a-sass-stylesheet
Adding a Sass Stylesheet | Create React App
July 7, 2021 - @use 'styles/_colors.scss'; // assuming a styles directory under src/ @use '~nprogress/nprogress'; // loading a css file from the nprogress node module Copy · Note: You can prefix paths with ~, as displayed above, to resolve modules from node_modules. ... To use imports relative to a path you specify, you can add a .env file at the project root with the path specified in the SASS_PATH environment variable.
Discussions

How to use Sass in React?
What you can do is use css modules and scss together. npm install sass Create a file called "test.module.scss" Import the file into the file you need those styles import styles from"./test.module.scss", you can call the "styles" import what you want. Use the styles from the file Ex.

lorem ipsum

More on reddit.com
🌐 r/reactjs
7
6
April 19, 2022
How do i use Sass with react?
Three ways. Just import the sass file in your component. Drop a class on the component top level, then scope your sass to that. Simple and easy. CRA and Vite support this out of the box. You have to manually manage the cascade, but if you know CSS this is not actually a huge problem. Sass modules. Write your sass, then import the class names. Apply those class names to the elements in your components. This is popular because your CSS is definitively scoped and nicely typed. Styled components. Not technically SASS, but the syntax is very similar, so you’ll feel comfortable right away. A styled component is a regular React component with styles attached using template syntax. Nice simple syntax and very easy to maintain. Pass props to your styles like any other component. Some concerns about performance if you use it badly. Use the one that suits. Different solutions for different problems. More on reddit.com
🌐 r/reactjs
8
6
October 23, 2023
Vite + React + Tailwind CSS starter
Hi everyone. This is a simple setup using Vite, React and Tailwind for faster prototyping. All the code present here is part of a free sample from Tailwind UI Repo: https://github.com/sorxrob/vite-react-tailwind-starter FYI: It's using the free sample components from here https://tailwindui.com/preview Vite Repo: https://github.com/vitejs/vite More on reddit.com
🌐 r/reactjs
21
63
August 12, 2020
Is it convenient to install Sass/Scss on React to edit Bootstrap variables?
Create react app V2 has sass/scss support built in. You can use the current create react app and simply upgrade the react scripts to V2. I’d provide more detail but I am at lunch. Then import your main scss file into your app. Done. OK - here's how you do it. After you use create react app you can simply update the scripts: { "name": "react-vds", "version": "0.1.0", "private": true, "dependencies": { "@fortawesome/fontawesome-svg-core": "^1.2.0", "@fortawesome/free-brands-svg-icons": "^5.1.0", "@fortawesome/free-regular-svg-icons": "^5.1.0", "@fortawesome/free-solid-svg-icons": "^5.1.0", "@fortawesome/react-fontawesome": "^0.1.0", "animate.css": "^3.6.1", "bootstrap": "^4.1.2", "prop-types": "^15.6.2", "react": "^16.4.1", "react-dom": "^16.4.1", "react-helmet": "^5.2.0", "react-notifications-component": "^0.1.1", "react-particles-js": "^2.2.0", "react-router-dom": "^4.3.1", "react-scripts": "2.0.0-next.a671462c" <=== Here }, $ yarn add react-scripts@2.0.0-next.a671462c Then add Bootstrap: $ yarn add bootstrap Then create a scss folder in src: $ cd src && mkdir scss Copy the main bootstrap scss file here and change the paths: /*! * Bootstrap v4.1.1 (https://getbootstrap.com/) * Copyright 2011-2018 The Bootstrap Authors * Copyright 2011-2018 Twitter, Inc. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) */ // Core variables and mixins @import '../../node_modules/bootstrap/scss/functions'; @import '../../node_modules/bootstrap/scss/variables'; @import '../../node_modules/bootstrap/scss/mixins'; @import '../../node_modules/bootstrap/scss/root'; @import '../../node_modules/bootstrap/scss/reboot'; ... etc. Then make a main.scss file an import the bootstrap code and override anything you need, plus you can add in any custom files. Mine looks like this: // Theming bootstrap // https://getbootstrap.com/docs/4.0/getting-started/theming/ // // Every Sass variable in Bootstrap 4 includes the !default flag allowing // you to override the variable’s default value in your own Sass without // modifying Bootstrap’s source code. Copy and paste variables as needed, // modify their values, and remove the !default flag. If a variable has // already been assigned, then it won’t be re-assigned by the default // values in Bootstrap. // To modify an existing color in our $theme-colors map // To add a new color to $theme-colors, add the new key and value: $theme-colors: ( 'primary': #7256ad, 'special': #000, ); // then import Bootstrap @import 'bootstrap'; // then load custom components @import 'nav'; @import 'masthead'; @import 'footer'; @import 'particles'; @import 'svg'; @import 'hero'; Finally import the main scss in your app: import React, { Fragment } from 'react'; import { Switch, Route } from 'react-router-dom'; // components import Navigation from './components/Navigation'; import Footer from './components/Footer'; // pages import PageLanding from './pages/PageLanding'; import PageTerms from './pages/PageTerms'; import PagePrivacy from './pages/PagePrivacy'; import PageAbout from './pages/PageAbout'; import PageNotFound from './pages/PageNotFound'; import PageContact from './pages/PageContact'; import PageToast from './pages/PageToast'; // routes import * as routes from './constants/routes'; // our main css import './scss/main.scss'; <==== Here ... etc. Last step - add node-sass $ yarn add node-sass Everything should work. I hope... More on reddit.com
🌐 r/reactjs
25
7
September 22, 2018
🌐
W3Schools
w3schools.com › react › react_sass_styling.asp
React Sass Styling
To add Sass to a React project, you need to install the Sass package: ... Now you are ready to include Sass files in your project! Create a Sass file the same way as you create CSS files, but Sass files have the file extension .scss:
🌐
Reddit
reddit.com › r/reactjs › how to use sass in react?
r/reactjs on Reddit: How to use Sass in React?
April 19, 2022 -

Hey,

So far in my React projects I've been putting all my Sass files in a "styles" folder inside src. Basically I import the files that correspond to each component into the main Sass file that's then compiled to CSS. But I get why this wouldn't be a scalable solution, as the number of files grows it could get confusing to know which Sass file corresponds to which JS component.

I know there's styled components, which is definitely something I'm going to try in my next project, but for the current one I want to use Sass. So I tried using CSS modules but it's really tedious to have to import every Sass class as a variable into the JS component. Unless I'm missing something.

I guess another alternative to what I've been doing would be to have the Sass files in the same folder as their respective components and then still import everything into the main Sass file. But for some reason this doesn't feel right, so is there a better way to use Sass in React?

Top answer
1 of 3
3
What you can do is use css modules and scss together. npm install sass Create a file called "test.module.scss" Import the file into the file you need those styles import styles from"./test.module.scss", you can call the "styles" import what you want. Use the styles from the file Ex.

lorem ipsum

2 of 3
1
CSS modules are a bit overrated if you just pick and use a decent prefix for all class names, although you're definitely overstating the tedium However, I think you're a bit misunderstanding what webpack does for you: > I guess another alternative to what I've been doing would be to have the Sass files in the same folder as their respective components and then still import everything into the main Sass file To be clear, this is the best pattern: component-scoped styles sit in a folder alongside the component JSX/TSX file, and they only impact that component. However, you don't need to "import everything into the main sass file", you just do this: MyComponent index.tsx style.scss MyComponent/style.scss: .PrefixedMyComponent { border: 1px solid var(--theme-border); border-radius: 8px; ... } MyComponent/index.tsx: // dependencies import React from 'react'; // styles import './style.scss'; export interface IMyComponentProps { children: any; // I have a type called RenderableContent for this situation } export function MyComponent(props: IMyComponentProps) { return {props.children}; } Then webpack makes one big browser-compatible CSS file for you when you run the "build" command
🌐
GeeksforGeeks
geeksforgeeks.org › how-to-install-node-sass-to-react-project
How to install node-sass to React project? - GeeksforGeeks
October 5, 2021 - Prerequisite: Basic knowledge of ReactJS · Installation process: Adding sass using npm: npm install node-sass --save · Adding sass using yarn: yarn add node-sass · Note: Now you can rename App.css to App.scss and update App.js to import App.scss.
🌐
YouTube
youtube.com › devtamin
How to use Sass in React with Vite - YouTube
In this video, I will teach you how to install Sass in React and Vite.js to use SCSS. SCSS will help you style a component easily in React with Vite. I will ...
Published   June 27, 2023
Views   21K
Find elsewhere
🌐
MakeUseOf
makeuseof.com › home › programming › how to use sass in react
How to Use Sass in React
July 1, 2023 - You can start using Sass in React by installing the sass package via npm or yarn, updating your CSS files to .scss or .sass, then updating your imports to use the new file extension.
🌐
Medium
medium.com › @subodha.sahu91 › 4-steps-to-add-sass-scss-to-react-typescript-project-d371d8f6968b
4 Steps to Add SASS/SCSS to React Typescript Project | by Subodha Sahu | Medium
May 15, 2023 - For example, importing the styles.scss file in a Button component: import React from 'react'; import './styles.scss'; interface ButtonProps { onClick: () => void; } const Button: React.FC<ButtonProps> = ({ onClick, children }) => { return ( ...
🌐
YouTube
youtube.com › watch
React and Sass Tutorial - Intro to SASS - YouTube
Hey guys in this video I will show you how to configure and setup sass in a React environment. Then I will show you the fundamental features existing in the ...
Published   June 8, 2021
🌐
GeeksforGeeks
geeksforgeeks.org › reactjs › how-to-style-with-sass-scss-in-react
How to style with SASS/SCSS in React ? - GeeksforGeeks
July 23, 2025 - //app.scss .gfg { background-color: green; padding: 5px; padding-left: 15px; h1 { color: white; font-family: sans-serif; } } Step to Run Application: Run the application using the following command from the root directory of the project: ... Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
🌐
YouTube
youtube.com › digitalocean
React Starters: #4 Adding Sass to Create React App - YouTube
Adding Sass is one of the first things most developers do when starting an application. Writing in plain CSS can be done, but Sass provides much more power w...
Published   April 27, 2020
Views   4K
🌐
Medium
medium.com › @bobjunior542 › how-to-use-scss-in-reactjs-f62433a126f5
How to use SCSS in Reactjs | by Bob Junior | Medium
March 8, 2023 - The node-sass package is the actual ... that allows you to use SCSS in your Webpack-based build process. Once you have installed the dependencies, you can update your Webpack configuration to use the sass-loader.
🌐
Medium
medium.com › officialrajdeepsingh › how-to-add-scss-sass-in-react-js-6615b6e77e56
How to add scss/sass in react.js? | by Rajdeep singh | Rajdeep Singh | Medium
December 13, 2021 - According to Wikipedia, sass is a preprocessor scripting language interpreted or compiled into Cascading Style Sheets (CSS). ... If you use the create-react-app in your project, use npm, you can easily install and use Sass ...
🌐
DEV Community
dev.to › jlargs64 › how-to-add-sass-to-your-create-react-app-in-2022-4c8e
How to add sass to your create-react-app in 2022 - DEV Community
January 5, 2022 - Then, create a Sass file in the src directory of your React app, we'll call ours main.scss
🌐
DEV Community
dev.to › readymadecode › how-to-use-scss-in-react-4jja
How to use SCSS in React? - DEV Community
April 2, 2023 - Sass files have the file extension .scss. And Now import your .scss file in your react component.
🌐
DEV Community
dev.to › officialrajdeepsingh › how-to-add-scss-sass-in-react-js-58hg
How to add scss/sass in react.js? - DEV Community
May 3, 2021 - Steps: 1.Install node-sass: npm install node-sass 2.Change file extension .css to .scss 3.Import your .scss files in your React components
🌐
Jointjs
resources.jointjs.com › tutorials › joint › tutorials › ReactTs.html
JointJS+ - React example app with TypeScript and SCSS using create-react-app
Next, open the "tsconfig.json" ... let's clean up our project a little bit: ... import React from 'react'; import './App.scss'; // import './App.css'; - if using native CSS function App() { return (); } export default App;...
🌐
GitHub
github.com › philosophie › react-sass-styleguide
GitHub - philosophie/react-sass-styleguide: Example Create React app using Sass and Bootstrap · GitHub
We've picked Bootstrap for this project, and since we're using React, we'll bring in React Bootstrap. ... Note: If you need to 'customize' the default Bootstrap theme, create a _custom.scss file inside the styles/settings folder.
Starred by 9 users
Forked by 2 users
Languages   JavaScript 63.8% | CSS 26.0% | HTML 10.2%