Sass is the CSS preprocessor that most professional front-end teams use. It is CSS with the features CSS was missing for years: variables, nesting, mixins, functions, and partials. You write .scss files, Sass compiles them to plain CSS, and your stylesheets become dramatically easier to maintain.
The difference shows up the moment a project grows. In plain CSS, a colour used in forty places is forty chances to make a typo. In Sass, it is one variable. In plain CSS, a component's styles scatter across a file. In Sass, they nest inside one block that mirrors your HTML.
npm install -D sass npx sass src/main.scss dist/main.css
Enter fullscreen mode
Exit fullscreen mode
$primary : #2563eb ; $radius : 8px ;
@mixin card { border-radius : $radius ; box-shadow : 0 2px 8px rgb ( 0 0 0 / 0.1 ) ; padding : 1rem ; }
.profile-card { @include card ; background : white ;
h2 { color : $primary ; margin : 0 0 0.5rem ; }
p { color : #555 ; } }
Enter fullscreen mode
Exit fullscreen mode
Sass is a great fit for any…