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
64
votes
8 answers

Solving the 'npm WARN saveError ENOENT: no such file or directory, open '/Users//package.json'' error

I'm a newbie so please include links to URLs or explain terminologies so I can understand. I've managed to install 'npm' on a Mac OS (10.13.3) via the terminal, and have installed some packages like SASS using it. I'm now trying to install sass-mq…
nkhil
  • 1,452
  • 1
  • 18
  • 37
63
votes
1 answer

SASS :not selector

I have a :not css selector in SASS mixin but it doesn't do anything: Code Snippet: @mixin dropdown-pos($pos:right) { &:not(.notip) { @if $comp-tip == true{ @if $pos == right { top:$dropdown-width * -0.6; @include…
user2667409
  • 1,169
  • 2
  • 9
  • 12
62
votes
12 answers

Next.js Global CSS cannot be imported from files other than your Custom

My React App was working fine, using global CSS also. I ran npm i next-images, added an image, edited the next.config.js file, ran npm run dev, and now I'm getting this message: Global CSS cannot be imported from files other than your Custom .…
IndustryDesigns
  • 1,938
  • 2
  • 12
  • 22
62
votes
25 answers

Sass "Error: Can't find stylesheet to import."

I'm running into an issue which seems similar to the one reported in https://github.com/sass/dart-sass/issues/284, but doesn't seem 'fixed' for me. I'm trying to follow the workflow described in…
Kurt Peek
  • 52,165
  • 91
  • 301
  • 526
60
votes
5 answers

Less/Sass debugging in Chrome Dev Tools/Firebug

How do you guys do maintenance on CSS built with Less/Sass? One of the things I like about Dev Tools/Firebug is the ability to see the line number of a css styling. Is there a good way to do this with CSS preprocessors other than having to manually…
Dave Stibrany
  • 2,369
  • 3
  • 21
  • 21
60
votes
6 answers

How to make Rails 3.1 use SASS (Over SCSS) as the default?

Having a hard time figuring out how to make SASS, not SCSS, as the default for stylesheets. I've tried making a sass_config.rb file with this: Sass::Plugin.options[:syntax] = :sass Sass::Plugin.options[:style] = :compressed I've also tried adding…
krainboltgreene
  • 1,841
  • 2
  • 17
  • 25
59
votes
3 answers

Checking if a variable is defined in SASS

AS the title says I am trying to check whether a variable is defined in SASS. (I am using compass if that makes any different difference) I've found the Ruby equivalent which is: defined? foo Gave that a shot in the dark but it just gave me the…
locrizak
  • 12,192
  • 12
  • 60
  • 80
59
votes
8 answers

Creating CSS3 Circles connected by lines

I have to implement the following circle and line combination in CSS and I am looking for pointers on how to implement this effectively. The circles and lines should look like this: I am able to implement the circles as such: span.step { …
HGandhi
  • 1,586
  • 2
  • 14
  • 27
59
votes
5 answers

Using sass with Flask and jinja2

I would like to include a sass compiler in my Flask application. Is there a generally accepted way of doing this?
kasperhj
  • 10,052
  • 21
  • 63
  • 106
58
votes
6 answers

How to properly introduce a light/dark mode in Bootstrap?

I use Bootstrap 4.5 and use bg-dark in my HTML template. I would like to implement a "light/dark" switch. So, Bootstrap has a bg-light css class, but I am not sure what the current approach how to use it. Let me clarify my confusion: Am I supposed…
Daniel Stephens
  • 2,371
  • 8
  • 34
  • 86
58
votes
6 answers

SCSS Import Relative to Root

I'm in the process refactoring an Angular application and as I'm moving components around to new directory locations, I'm finding that dealing @import paths in the components' SCSS files is getting a bit tedious. For example, let's say I have the…
Steve
  • 11,596
  • 7
  • 39
  • 53
58
votes
3 answers

Select only direct children from element with Sass

Lets say I have the following html:

Home

56
votes
12 answers

Rails: Sprockets::Rails::Helper::AssetNotPrecompiled in development

I am relatively new to Rails and I am trying to use the asset pipeline, SCSS, in the development environment. However, after I created the controller, the view, and the css.scss file, I encounter the following…
Sydney
  • 1,349
  • 1
  • 14
  • 20
56
votes
4 answers

Have sass-lint ignore a certain line?

I'm using sass-lint with Gulp. How can I disable warnings for a particular style in my sass from the lint console output? I've found a similar question but I'm using sass-lint, not scss-lint: Having scss-lint ignore a particular line This is the…
Evanss
  • 23,390
  • 94
  • 282
  • 505
56
votes
6 answers

Disable map files on SASS

I would like to know how I can prevent Sass from writing .map files. I'm using Sass in a very basic setup: sass --watch style.scss:style.css what parameters do I have to add to avoid Sass to generate map files?
supersize
  • 13,764
  • 18
  • 74
  • 133