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
97
votes
10 answers

Nuxtjs vuetify throwing lots of `Using / for division is deprecated and will be removed in Dart Sass 2.0.0.`

Nuxtjs using vuetify throwing lots of error Using / for division is deprecated and will be removed in Dart Sass 2.0.0. during yarn dev Nuxtjs: v2.15.6 @nuxtjs/vuetify": "1.11.3", "sass": "1.32.8", "sass-loader": "10.2.0", Anyone know how to fix it…
kwong ho
  • 973
  • 1
  • 6
  • 7
96
votes
1 answer

Attaching a SCSS to HTML docs

Hello I am new to web design. I would like to learn how to attach an SCSS file to an HTML file in the head tag : I tried this but did not see the result. I guess that it's like the LESS…
Cato Cato
  • 973
  • 1
  • 6
  • 8
95
votes
15 answers

Is there a way I can overwrite the colour the Material UI Icons npm package provides in React?

I am new to React and am using the npm package Material UI icons (https://www.npmjs.com/package/@material-ui/icons) and displaying icons within a React component as such: Importing: import KeyboardArrowRightIcon from…
MeltingDog
  • 14,310
  • 43
  • 165
  • 295
91
votes
5 answers

How to compile Less/Sass files in Visual Studio 2017+

In VS <= 2015 we can use a WebEssentials extension that takes care for compiling the less/sass files for us, but currently it does not support VS 2017. Is there a similar extension that can compile Less/Sass on build?
Mihail Shishkov
  • 14,129
  • 7
  • 48
  • 59
91
votes
3 answers

How to dynamically generate a list of classes with commas separating them?

I'm working with the SCSS syntax of SASS to create a dynamic grid system but I've hit a snag. I'm trying to make the grid system completely dynamic like this: $columns: 12; then I create the columns like this: @mixin col-x { @for $i from 1…
Josh
  • 5,999
  • 8
  • 30
  • 43
91
votes
9 answers

Optimize Font Awesome for only used classes

I am using Font Awesome Sass file https://github.com/FortAwesome/Font-Awesome/blob/master/sass/font-awesome.sass to make it _font-awesome.sass so I can @import in my Sass project. I am also using http://middlemanapp.com/ to convert Sass to Css.…
HP.
  • 19,226
  • 53
  • 154
  • 253
90
votes
7 answers

How to add SCSS styles to a React project?

I'm just starting to learn React (have some JavaScript knowledge, as I'm learning tis as well) and building my first project. I would like to know how to add styles to my first React project, using CSS/SCSS as I have some knowledge and understanding…
Will
  • 1,001
  • 1
  • 6
  • 12
90
votes
9 answers

How do I load font-awesome using SCSS (SASS) in Webpack using relative paths?

I have font-awesome in my node_modules folder so I try to import it in my main .scss file like so: @import "../../node_modules/font-awesome/scss/font-awesome.scss"; But Webpack bundling compilation fails, telling me Error: Cannot resolve 'file' or…
Richard
  • 14,798
  • 21
  • 70
  • 103
89
votes
6 answers

Proper SCSS Asset Structure in Rails

So, I have an app/assets/stylesheets/ directory structure that looks something like this: |-dialogs |-mixins |---buttons |---gradients |---vendor_support |---widgets |-pages |-structure |-ui_elements In each directory,…
David Savage
  • 1,562
  • 2
  • 18
  • 35
88
votes
9 answers

how to watch changes in whole directory/folder containing many sass files

How could I trace changes in whole directory containing many sass files ? I'm using the following command to watch changes in sass file: sass --watch style.scss:style.css But how to watch changes in whole directory/folder containing many sass…
JA9
  • 1,708
  • 3
  • 14
  • 18
85
votes
3 answers

@each loop with index

I was wondering if you can get an element index for the @each loop. I have the following code, but I was wondering if the $i variable was the best way to do this. Current code: $i: 0; $refcolors: #55A46A, #9BD385, #D9EA79, #E4EE77, #F2E975, #F2D368,…
ignacioricci
  • 1,236
  • 1
  • 8
  • 9
84
votes
2 answers

Sass Invalid CSS Error: "expected expression"

I've just been following the Sass tutorial. For some reason though the Sass file is not correctly generating the css. The terminal says the css is invalid but I'm pretty sure it's not. I've tried changing it too just in case there was a problem...…
Tom R
  • 1,783
  • 2
  • 14
  • 14
84
votes
1 answer

Setting opacity on $primary-color in sass

Is there an option to include opacity on the colors you define to be your primary/secondary colors in the sass variables? In the fashion of the lighten($color, amount) function?
Furi
  • 1,015
  • 1
  • 9
  • 6
82
votes
13 answers

SASS CSS: Target Parent Class from Child

I am using SASS and found an inconvenience. This is an example of what I am trying to do: .message-error { background-color: red; p& { background-color: yellow } } Expected CSS: .message-error { background-color:…
Zeljko
  • 5,048
  • 5
  • 36
  • 46
82
votes
2 answers

Why does Sass cache folder get created

I have started trying out Sass for my css work. In the directory where my Css file resides I see a '.sass-cache' folder too. Can any one tell me why is this folder created and is it safe if I delete it. thanks,
Pav
  • 1,156
  • 1
  • 7
  • 10