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
246
votes
27 answers

Browserslist: caniuse-lite is outdated. Please run next command `npm update caniuse-lite browserslist`

Recently, when I compile my scss files I get an error. The error message says: Browserslist: caniuse-lite is outdated. Please run next command npm update caniuse-lite browserslist First, as the message says, I ran npm update caniuse-lite…
Nick Mehrdad Babaki
  • 11,560
  • 15
  • 45
  • 70
246
votes
13 answers

Is it possible to import a whole directory in sass using @import?

I'm modularizing my stylesheets with SASS partials like so: @import partials/header @import partials/viewport @import partials/footer @import partials/forms @import partials/list_container @import partials/info_container @import…
corroded
  • 21,406
  • 19
  • 83
  • 132
233
votes
22 answers

Can't import CSS/SCSS modules. TypeScript says "Cannot Find Module"

I'm trying to import a theme from a CSS module but TypeScript gives me a "Cannot Find Module" error and the theme isn't applied on runtime. I think there's something wrong with my Webpack config but I'm not sure where the problem is. I'm using the…
zakdances
  • 22,285
  • 32
  • 102
  • 173
232
votes
1 answer

:after and :before pseudo-element selectors in Sass

How can I use the :before and :after pseudo-element selectors following the syntax of Sass or, alternatively, SCSS? Like this: p margin: 2em auto > a color: red :before content: "" :after content: "* * *" Of course, the above…
Marco Godínez
  • 3,440
  • 2
  • 21
  • 30
231
votes
34 answers

Node Sass does not yet support your current environment: Linux 64-bit with false

Getting this error on Arch Linux with node-sass. I'm using it with gulp-sass. Node Sass does not yet support your current environment: Linux 64-bit with false Versions $ gulp -v [19:43:15] CLI version 3.9.1 [19:43:15] Local version 3.9.1 $ npm…
Jitendra Vyas
  • 148,487
  • 229
  • 573
  • 852
222
votes
13 answers

Making a Sass mixin with optional arguments

I am writing a mixin like this: @mixin box-shadow($top, $left, $blur, $color, $inset:"") { -webkit-box-shadow: $top $left $blur $color $inset; -moz-box-shadow: $top $left $blur $color $inset; box-shadow: $top $left $blur $color…
Rich Bradshaw
  • 71,795
  • 44
  • 182
  • 241
211
votes
6 answers

What is the difference between CSS and SCSS?

I know CSS very well, but am confused about Sass. How is SCSS different from CSS, and if I use SCSS instead of CSS will it work the same?
Urvi_204
  • 2,308
  • 2
  • 10
  • 23
205
votes
17 answers

Angular-cli from css to scss

I've read the documentation, which says that if I want to use scss I have to run the following command: ng set defaults.styleExt scss But when I do that and make that file, I still receive this error in my console: styles.bundle.js:33Uncaught…
Jamie
  • 10,302
  • 32
  • 103
  • 186
183
votes
3 answers

Vue CLI CSS pre-processor option: dart-sass VS node-sass?

When creating a new project with CLI (v3.7.0), there is an option to choose between dart-sass or node-sass compiler. How do these compare to each other, to be more specific than declared in Vue docs? A Tip on Sass Performance Note that when using…
ux.engineer
  • 10,082
  • 13
  • 67
  • 112
179
votes
7 answers

How do I use /deep/ or >>> or ::v-deep in Vue.js?

So, I've read here that in Vue.js, you can use /deep/ or >>> in a selector in order to create style rules that apply to elements inside of child components. However, attempting to use this in my styles, whether in SCSS or in plain old CSS, doesn't…
laptou
  • 6,389
  • 2
  • 28
  • 59
170
votes
2 answers

What are Compass and Sass and how do they differ?

I would like to start using Compass and Sass to speed up development. At the moment, I have installed Sass on a mac and instructed it to watch a Scss file for input, and a CSS file for generated output. From many articles, Sass is used with Compass,…
Chiko
  • 2,330
  • 4
  • 21
  • 29
168
votes
9 answers

Change text color based on brightness of the covered background area?

I am looking for a plugin or technique that changes a text's color or switches between predefined images/icons depending on the average brightness of the covered pixels of its parent's background-image or -color. If the covered area of it's…
James Cazzetta
  • 3,122
  • 6
  • 32
  • 54
167
votes
8 answers

Using Sass Variables with CSS3 Media Queries

I'm trying to combine the use of a Sass variable with @media queries as follows: $base_width:1160px; @media screen and (max-width: 1170px) {$base_width: 960px;} @media screen and (min-width: 1171px) {$base_width: 1160px;} $base_width is then…
Jeremy S.
  • 4,599
  • 3
  • 18
  • 25
161
votes
8 answers

Why don’t SVG images scale using the CSS “width” property?

HTML
Facebook LinkedIn Instagram
CSS using SASS #hero { display: flex; …
Pine Code
  • 2,466
  • 3
  • 18
  • 43
158
votes
20 answers

Node Sass does not yet support your current environment: Windows 64-bit with Unsupported runtime (88)

I have tried to install gulp-sass latest version with npm i gulp-sass --save-dev in the begining I got a lot of errors but later solved them. But whenever I try to run gulp I got this error: Error: Node Sass does not yet support your current…
DINA TAKLIT
  • 7,074
  • 10
  • 69
  • 74