Questions tagged [sass]

Sass (Syntactically Awesome Style Sheets) is an extension of CSS adding features like nested rules, variables, mixins and class extensions. This enables developers to write structured, manageable and reusable CSS. Sass is compiled into standard CSS. It is primarily a CSS pre-processor language that accepts both the CSS and its personalised syntax of writing visual design codes.

Overview:

Sass is a meta-language on top of that describes the style of a document cleanly and structurally, with more power than flat CSS allows.

Sass is an extension of written in . It adds nested rules, variables, mixins, selector inheritance, and useful functions like color manipulation or conditional statements2. It's translated to well-formatted, standard CSS using the command-line tool or a web-framework plugin.

It is the only language that can store design tokens (e.g. colors, font sizes, spacing) and use the value types9 natively; i.e. numbers, colors, strings, lists, and booleans.

Sass has two syntaxes:

  1. SCSS (Sassy CSS): As of Sass3, this is the main syntax. It is a superset of CSS3, so all valid CSS files are also valid SCSS. Files with this syntax have the extension .scss.

Example SCSS:

$margin: 12px;

li {
  .border {
    margin: $margin / 2;
  }
}
  1. SASS: The indented syntax. Instead of braces and semicolons, it uses line indentation to specify blocks (similar to Ruby's syntax). Files with this syntax have the extension .sass.

Example SASS:

$margin: 12px

li
  .border
    margin: $margin / 2

Frameworks / Extensions:

  • 4 is an extension of Sass which provides pre-defined cross-browser mixins and additional functionality like automated sprite-generation.
  • 5 is a simple and lightweight mixin library for Sass.

Flavors:

  • Ruby Sass1 is the original Ruby-based version of Sass.
  • LibSass6 is C/C++ port of the Sass precompiler. It compiles very quickly, can be embedded in other languages and binaries, and aims for feature parity with the original Ruby Sass.
  • Node Sass7 uses LibSass to compile .scss files using Node.

Links:


Resources:

27250 questions
2441
votes
17 answers

What's the difference between SCSS and Sass?

From what I've been reading, Sass is a language that makes CSS more powerful with variable and math support. What's the difference with SCSS? Is it supposed to be the same language? Similar? Different?
bbonamin
  • 30,042
  • 7
  • 40
  • 49
1838
votes
6 answers

Sass Variable in CSS calc() function

I'm trying to use the calc() function in a Sass stylesheet, but I'm having some issues. Here's my code: $body_padding: 50px body padding-top: $body_padding height: calc(100% - $body_padding) If I use the literal 50px instead of my…
GJK
  • 37,023
  • 8
  • 55
  • 74
876
votes
44 answers

How to fix "ReferenceError: primordials is not defined" in Node.js

I have installed Node.js modules by 'npm install', and then I tried to do gulp sass-watch in a command prompt. After that, I got the below response. [18:18:32] Requiring external module babel-register fs.js:27 const { Math, Object, Reflect } =…
Ramesh
  • 8,921
  • 3
  • 18
  • 14
649
votes
23 answers

Error: 'node-sass' version 5.0.0 is incompatible with ^4.0.0

I've created a blank React project, using the command: npx create-react-app on npm v7.0.7 and Node.js v15.0.1 Installed: React v17.0.1, node-sass v5.0.0, Then I tried to import a blank .scss file to the App component: File App.js import…
JDKot
  • 6,643
  • 2
  • 10
  • 12
592
votes
15 answers

Import regular CSS file in SCSS file?

Is there anyway to import a regular CSS file with Sass's @import command? While I'm not using all of the SCSS syntax from sass, I do still enjoy it's combining/compressing features, and would like to be able to use it without renaming all of my…
GSto
  • 41,512
  • 37
  • 133
  • 184
489
votes
2 answers

Sass Nesting for :hover does not work

I've written this code, but it does not work. What is my problem? .class { margin:20px; :hover { color:yellow; } }
Beach Boys
  • 5,029
  • 2
  • 14
  • 7
469
votes
6 answers

Sass .scss: Nesting and multiple classes?

I'm using Sass (.scss) for my current project. Following example: HTML
Hello World
SCSS .container { background:red; color:white; .hello { …
matt
  • 42,713
  • 103
  • 264
  • 397
421
votes
6 answers

Including another class in SCSS

I have this in my SCSS file: .class-a{ display: inline-block; //some other properties &:hover{ color: darken(#FFFFFF, 10%); } } .class-b{ //Inherite class-a here //some properties } In class-b, I would like to inherite all…
F21
  • 32,163
  • 26
  • 99
  • 170
365
votes
18 answers

Angular CLI SASS options

I'm new to Angular and I'm coming from the Ember community. Trying to use the new Angular-CLI based on Ember-CLI. I need to know the best way to handle SASS in a new Angular project. I tried using the ember-cli-sass repo to see if it would play…
JDillon522
  • 19,046
  • 15
  • 47
  • 81
355
votes
13 answers

Using fonts with Rails asset pipeline

I have some fonts being configured in my Scss file like so: @font-face { font-family: 'Icomoon'; src: asset-url('icoMoon.eot?#iefix', font) format('embedded-opentype'), asset-url('icoMoon.woff', font) format('woff'), …
rctneil
  • 7,016
  • 10
  • 40
  • 83
338
votes
8 answers

SASS - use variables across multiple files

I would like to keep one central .scss file that stores all SASS variable definitions for a project. // _master.scss $accent: #6D87A7; $error: #811702; $warning: #F9E055; $valid: #038144; // etc... The project will have a large number…
dthree
  • 19,847
  • 14
  • 77
  • 106
297
votes
5 answers

sass --watch with automatic minify?

Is there a way to run: sass --watch a.scss:a.css but have a.css end up being minified? How would I avoid having to run a separate minification step as I compile my stylesheet?
tester
  • 22,441
  • 25
  • 88
  • 128
270
votes
6 answers

Sass - Converting Hex to RGBa for background opacity

I have the following Sass mixin, which is a half complete modification of an RGBa example: @mixin background-opacity($color, $opacity: .3) { background: rgb(200, 54, 54); /* The Fallback */ background: rgba(200, 54, 54, $opacity); } I have…
Rick Donohoe
  • 7,081
  • 6
  • 26
  • 38
269
votes
17 answers

Try reinstalling `node-sass` on node 0.12?

I would like to use google web starter kit. I installed node.js v0.12.0, node-sass & gulp. And then ran: $ sudo npm install When I typed gulp serve then got this error: Using gulpfile ~/web-starter-kit/gulpfile.js Starting 'styles'... 'styles'…
Takagi Akihiro
  • 2,691
  • 2
  • 12
  • 5
258
votes
7 answers

Why put in front of the file name "_" or "_" in scss/css?

Why put _ in front of the filename in scss? _filename.scss - Why does it need _ ?
Niko_D
  • 2,787
  • 2
  • 10
  • 7
1
2 3
99 100