CORE CONCEPTS
CSS Preprocessors
Rasengan.js supports popular CSS preprocessors like Sass, Less, and Stylus. These tools make writing CSS easier by adding features like variables, nested rules, and functions.
Using a Preprocessor
To use a preprocessor, install the required package and create a stylesheet with the correct file extension. Then, import the file into your components.
Sass (.scss / .sass)
Sass adds features like variables and nesting to CSS. Rasengan.js supports it once you install the sass package.
1. Install Sass
npm install --save-dev sass
2. Create a Sass File
$primary-color: #333; .my-component { color: $primary-color; }
3. Import It in a Component
import "./MyComponent.scss"; export default function MyComponent() { return <div className="my-component">Hello, world!</div>; }
Using Sass with CSS Modules
CSS Modules prevent class name conflicts by scoping styles locally. Use the .module.scss extension:
$primary-color: #333; .component { color: $primary-color; }
import styles from "./MyComponent.module.scss"; export default function MyComponent() { return <div className={styles.component}>Hello, world!</div>; }
Less (.less)
Less is another CSS preprocessor similar to Sass but uses @ for variables.
1. Install Less
npm install --save-dev less
2. Create a Less File
@primary-color: #333; .my-component { color: @primary-color; }
3. Import It in a Component
import "./MyComponent.less"; export default function MyComponent() { return <div className="my-component">Hello, world!</div>; }
Stylus (.styl / .stylus)
Stylus is a flexible preprocessor that allows cleaner, indentation-based syntax.
1. Install Stylus
npm install --save-dev stylus
2. Create a Stylus File
primary-color = #333 .my-component color primary-color
3. Import It in a Component
import "./MyComponent.styl"; export default function MyComponent() { return <div className="my-component">Hello, world!</div>; }
Tailwind CSS
Optimizing Images
