How to use SCSS in Syncfusion React Component?
Overview
This article is about using SCSS files in React application, created by using the “create-react-app” utility.
Prerequisite
- Node
- NPM
- Create React App
- Node SASS
Installing Node & NPM
For installing Node.js in your machine, download the LTS (Long Time Support) version of windows setup from the following link.
NPM (Node Package Manager) will be installed automatically along with Node.js setup.
Installing Create React App
Install the “create-react-app” utility package using the following NPM Command.
npm install -g create-react-app
Creating React Application
Use the following command to create react application.
Create-react-app ej2-react
Installing Node Sass Package
You can install the “node-sass” package using the following command.
npm install node-sass --save
|
Create .env file
Create .env file in the root directory of the React application for setting SASS include path variables.
Rename the “.css” to “.scss”
Rename all the CSS file extension with SCSS file extension.
Customizing Syncfusion Theme using the SCSS Variables
Now, you can customize the Syncfusion theme using the SCSS variables as follows.
$accent: blue; @import "../node_modules/@syncfusion/ej2-react-buttons/styles/material.scss";
You can refer the Syncfusion documentation to integrate Syncfusion React components into React application.
Conclusion
Now, run the application using “npm run start”.
npm run start
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/ej2-react-154008663
Conclusion
I hope you enjoyed learning about how to use SCSS in Syncfusion React Component.
You can refer to our React feature tour page to know about its other groundbreaking feature representations. You can also explore our documentation to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!