🎨
UI Component12M+/wkMIT

sass

Sass (Syntactically Awesome Style Sheets) is the most mature and widely used CSS preprocessor, extending CSS with variables, nesting, mixins, functions, inherit

Installation

npm
npm install -D sass
yarn
yarn add -D sass
pnpm
pnpm add -D sass

Import

ESM
// Import in JS: import './styles.scss';

Quick Example

usage
// styles.scss
$primary: #3b82f6;

@mixin flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.card {
  @include flex-center;
  background: $primary;
  border-radius: 8px;

  &:hover {
    background: darken($primary, 10%);
  }
}

About sass

Sass (Syntactically Awesome Style Sheets) is the most mature and widely used CSS preprocessor, extending CSS with variables, nesting, mixins, functions, inheritance, and modular file organization. The sass npm package provides the Dart implementation of Sass, which is the primary and most up-to-date implementation. Sass supports two syntaxes: SCSS (.scss), which is a superset of CSS with curly braces and semicolons, and the indented syntax (.sass), which uses indentation instead of braces. Key features include variables ($color: #333), nesting for mirroring HTML structure, mixins (@mixin) for reusable groups of declarations, functions for computing values, extends/inheritance for sharing style rules, partials for splitting stylesheets into manageable files, and operators for math operations. The @use and @forward module system provides namespace-based imports that replace the older @import. Sass compiles to standard CSS that browsers can interpret. While CSS has adopted some features Sass pioneered (custom properties, nesting), Sass still provides functionality beyond native CSS including mixins, extends, comprehensive math, and the module system. Sass is integrated into most build tools and frameworks including webpack, Vite, and Next.js.

Quick Facts

Packagesass
CategoryUI Component
Weekly Downloads12M+
LicenseMIT
Installnpm install -D sass

Related Packages

Browse npm Packages by Category

Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.