.scss and .sass syntax.
Installation
- npm
- pnpm
- yarn
- bun
Usage with CSS Modules
Use Sass with CSS Modules by creating a file with the.module.scss or .module.sass extension:
Global Sass
Import global.scss or .sass files in your root layout just like global CSS:
Configuring Sass options
To configure the Sass compiler, usesassOptions in next.config.js. You can pass any option supported by the sass package:
Using a custom Sass implementation
You can specify an alternative implementation such assass-embedded:
next.config.js
Shared variables with CSS Modules
To share Sass variables across all CSS Module files without importing them manually, use theadditionalData option:
next.config.js
styles/variables.scss
$primary-color and $font-size-base without an explicit @use import.
The
.scss (SCSS syntax) and .sass (indented syntax) file extensions are both supported. Choose one based on your team’s preference—SCSS is more common.