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
70
votes
5 answers

Append unit type to the result of a calculation in Sass

I've been refactoring my CSS to a SASS style sheet recently. I'm using the Mindscape Web Workbench extension for VS2012, which re-generates the CSS each time you save your SCSS. I started with code similar to this: /* Starting point: */ h1 {…
Jeroen
  • 60,696
  • 40
  • 206
  • 339
70
votes
6 answers

Sass support for Sublime Text 2?

Is there an existing package for editing Sass in Sublime Text 2? This seems to be popular: https://github.com/n00ge/sublime-text-haml-sass However, after installation, it appears that it only provides syntax highlighting for scss files. Ideally, I'd…
user1419762
  • 3,571
  • 5
  • 20
  • 10
69
votes
4 answers

Can I use variables for selectors?

I have this variable: $gutter: 10; I want to use it in a selector like so SCSS: .grid+$gutter { background: red; } so the output becomes CSS: .grid10 { background: red; } But this doesn't work. Is it possible?
Johansrk
  • 5,160
  • 3
  • 38
  • 37
68
votes
8 answers

SassError: Can't find stylesheet to import. @use '~@angular/material' as mat;

I created an Angular project using the CLI. I'm using SCSS, and I included Angular Material with a custom theme iirc. I added a couple dummy components, and the app still built fine. Then I needed to style my components using Angular Material. In…
Mathew Alden
  • 1,458
  • 2
  • 15
  • 34
68
votes
3 answers

Unable to set SCSS variable to CSS variable?

Consider the following SCSS: $color-black: #000000; body { --color: $color-black; } When it is compiled with node-sass version 4.7.2, it produces following CSS: body { --color: #000000; } When I compile the same SCSS with version 4.8.3…
Harshal Patil
  • 17,838
  • 14
  • 60
  • 126
68
votes
3 answers

How to set scss syntax in Sublime 3?

I'm using Sublime 3 editor. When I open a SCSS file it shows many red characters because it misjudged the syntax. When I press CTRL + Shift + P and type sass or scss I get no option. I had to set syntax to CSS. Is there any way to set syntax to…
user31782
  • 7,087
  • 14
  • 68
  • 143
68
votes
4 answers

How do I downgrade to an old version of compass using gem install?

I've been using compass from http://compass-style.org/ to manage my sites css for a long time. I just installed the newest version and I get a rather unpleasant error, that has as a side effect corrupted all my css files. How do I downgrade to an…
Matt Lynn
  • 683
  • 1
  • 5
  • 5
67
votes
5 answers

How to compile .sass files on save in Visual Studio 2015

How can one get a full sass (i.e. scss) precompiler environment up and running in Visual Studio 2015? This is a sibling question to this one concerning less.
Nicholas Petersen
  • 9,104
  • 7
  • 59
  • 69
67
votes
2 answers

Does SCSS support inline comments?

Can I keep an inline comment like this in my .scss file thead { display: table-header-group; // h5bp.com/t } I don't want this comment in my CSS output.
Jitendra Vyas
  • 148,487
  • 229
  • 573
  • 852
66
votes
3 answers

Webpack sass where is the css file

I am using web pack with sass loader like this: module.exports = { module: { loaders: [ { test: /\.scss$/, loader: "style!css!sass" } ] } }; But i see the styles apply to the style tag, where is the generate…
user4207046
66
votes
6 answers

Converts scss to css

Does anyone know how can I convert this code to standard css? It's not working in their editor. http://codepen.io/andymcfee/pen/eyahr
Barbara
  • 12,908
  • 6
  • 32
  • 43
65
votes
7 answers

access SASS values ($colors from variables.scss) in Typescript (Angular2 ionic2)

In Ionic 2, I would like to access the $colors variables from the file "[my project]\src\theme\variables.scss". This file contains: $colors: ( primary: #387ef5, secondary: #32db64, danger: #f53d3d, light: #f4f4f4, dark: …
nyluje
  • 3,573
  • 7
  • 37
  • 67
65
votes
4 answers

Media queries in Sass

I am wondering if there is a way to write media queries in sass, so I can give a certain style between let's say: 300px to 900px in css it looks like this @media only screen and (min-width: 300px) and (max-width: 900px){ } I know I can write…
Maciej S.
  • 1,773
  • 3
  • 12
  • 12
64
votes
8 answers

Cannot find module 'sass'

I wrote a React app and tried to dockerize it. After I do this it doesn't compile correctly, it doesn't find the sass module and the error is: Failed to…
Alora
  • 761
  • 1
  • 5
  • 12
64
votes
11 answers

Sass Loader Error: Invalid options object that does not match the API schema

I'm using VueJS with the framework VuetifyJS (v2.0.19). I'm getting this error after running npm run serve: Sass Loader has been initialised using an options object that does not match the API schema. What I tried: I've deleted the node_modules…
Tom
  • 5,588
  • 20
  • 77
  • 129