• This repository has been archived on 04/Apr/2019
  • Stars
    star
    181
  • Rank 212,110 (Top 5 %)
  • Language
    Ruby
  • License
    MIT License
  • Created over 6 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The original, now deprecated Ruby implementation of Sass

Ruby Sass Has Reached End-of-Life

Ruby Sass should no longer be used, and will no longer be receiving any updates. See the Sass blog, and consider switching to the sassc gem.

Sass Travis Build Status Gem Version Inline docs

Sass makes CSS fun again. Sass is an extension of CSS, adding nested rules, variables, mixins, selector inheritance, and more. It's translated to well-formatted, standard CSS using the command line tool or a web-framework plugin.

Sass has two syntaxes. The new main syntax (as of Sass 3) is known as "SCSS" (for "Sassy CSS"), and is a superset of CSS's syntax. This means that every valid CSS stylesheet is valid SCSS as well. SCSS files use the extension .scss.

The second, older syntax is known as the indented syntax (or just "Sass"). Inspired by Haml's terseness, it's intended for people who prefer conciseness over similarity to CSS. Instead of brackets and semicolons, it uses the indentation of lines to specify blocks. Although no longer the primary syntax, the indented syntax will continue to be supported. Files in the indented syntax use the extension .sass.

Using

Sass can be used from the command line or as part of a web framework. The first step is to install the gem:

gem install sass

After you convert some CSS to Sass, you can run

sass style.scss

to compile it back to CSS. For more information on these commands, check out

sass --help

To install Sass in Rails 2, just add config.gem "sass" to config/environment.rb. In Rails 3, add gem "sass" to your Gemfile instead. .sass or .scss files should be placed in public/stylesheets/sass, where they'll be automatically compiled to corresponding CSS files in public/stylesheets when needed (the Sass template directory is customizable... see the Sass reference for details).

Sass can also be used with any Rack-enabled web framework. To do so, just add

require 'sass/plugin/rack'
use Sass::Plugin::Rack

to config.ru. Then any Sass files in public/stylesheets/sass will be compiled into CSS files in public/stylesheets on every request.

To use Sass programmatically, check out the YARD documentation.

Formatting

Sass is an extension of CSS that adds power and elegance to the basic language. It allows you to use variables, nested rules, mixins, inline imports, and more, all with a fully CSS-compatible syntax. Sass helps keep large stylesheets well-organized, and get small stylesheets up and running quickly, particularly with the help of the Compass style library.

Sass has two syntaxes. The one presented here, known as "SCSS" (for "Sassy CSS"), is fully CSS-compatible. The other (older) syntax, known as the indented syntax or just "Sass", is whitespace-sensitive and indentation-based. For more information, see the reference documentation.

To run the following examples and see the CSS they produce, put them in a file called test.scss and run sass test.scss.

Nesting

Sass avoids repetition by nesting selectors within one another. The same thing works for properties.

table.hl {
  margin: 2em 0;
  td.ln { text-align: right; }
}

li {
  font: {
    family: serif;
    weight: bold;
    size: 1.2em;
  }
}

Variables

Use the same color all over the place? Need to do some math with height and width and text size? Sass supports variables, math operations, and many useful functions.

$blue: #3bbfce;
$margin: 16px;

.content_navigation {
  border-color: $blue;
  color: darken($blue, 10%);
}

.border {
  padding: $margin / 2;
  margin: $margin / 2;
  border-color: $blue;
}

Mixins

Even more powerful than variables, mixins allow you to re-use whole chunks of CSS, properties or selectors. You can even give them arguments.

@mixin table-scaffolding {
  th {
    text-align: center;
    font-weight: bold;
  }
  td, th { padding: 2px; }
}

@mixin left($dist) {
  float: left;
  margin-left: $dist;
}

#data {
  @include left(10px);
  @include table-scaffolding;
}

A comprehensive list of features is available in the Sass reference.

Executables

The Sass gem includes several executables that are useful for dealing with Sass from the command line.

sass

The sass executable transforms a source Sass file into CSS. See sass --help for further information and options.

sass-convert

The sass-convert executable converts between CSS, Sass, and SCSS. When converting from CSS to Sass or SCSS, nesting is applied where appropriate. See sass-convert --help for further information and options.

Running locally

To run the Sass executables from a source checkout instead of from rubygems:

$ cd sass
$ bundle
$ bundle exec sass ...
$ bundle exec scss ...
$ bundle exec sass-convert ...

Authors

Sass was envisioned by Hampton Catlin (@hcatlin). However, Hampton doesn't even know his way around the code anymore and now occasionally consults on the language issues. Hampton lives in San Francisco, California and works as VP of Technology at Moovweb.

Natalie Weizenbaum is the primary developer and architect of Sass. Her hard work has kept the project alive by endlessly answering forum posts, fixing bugs, refactoring, finding speed improvements, writing documentation, implementing new features, and designing the language. Natalie lives in Seattle, Washington and works on Dart application libraries at Google.

Chris Eppstein is a core contributor to Sass and the creator of Compass, the first Sass-based framework, and Eyeglass, a node-sass plugin ecosystem for NPM. Chris focuses on making Sass more powerful, easy to use, and on ways to speed its adoption through the web development community. Chris lives in San Jose, California with his wife and two children. He is an Engineer for LinkedIn.com, where his primary responsibility is to maintain Sass and many other Sass-related open source projects.

If you use this software, we'd be truly honored if you'd make a tax-deductible donation to a non-profit organization and then let us know on twitter, so that we can thank you. Here's a few that we endorse:

Sass is licensed under the MIT License.

More Repositories

1

sass

Sass makes CSS fun!
TypeScript
15,081
star
2

node-sass

🌈 Node.js bindings to libsass
C++
8,506
star
3

libsass

A C/C++ implementation of a Sass compiler
C++
4,331
star
4

dart-sass

The reference implementation of Sass, written in Dart.
Dart
3,913
star
5

sassc

libsass command line driver
C
785
star
6

sassc-rails

Integrate SassC-Ruby with Rails!
HTML
707
star
7

libsass-python

A straightforward binding of libsass for Python. Compile Sass/SCSS in Python with no Ruby stack at all!
Python
560
star
8

sassc-ruby

Use libsass with Ruby!
Ruby
365
star
9

sass-site

Sass Website
TypeScript
312
star
10

node-sass-middleware

connect middleware extracted from node-sass
JavaScript
263
star
11

sass-spec

Official Sass Spec Suite
SCSS
200
star
12

embedded-host-node

A Node.js library that will communicate with Embedded Dart Sass using the Embedded Sass protocol
TypeScript
149
star
13

node-sass-binaries

Platform specific binaries for node-sass
127
star
14

libsass-net

A lightweight wrapper around libsass
C#
95
star
15

migrator

Tool for migrating stylesheets to new Sass versions
Dart
84
star
16

ruby-libsass

Ruby bindings for libsass
Ruby
81
star
17

dart-sass-embedded

A wrapper for Dart Sass that implements the compiler side of the Embedded Sass protocol
Dart
66
star
18

linter

An experimental Sass linter written using the Dart Sass AST
Dart
39
star
19

homebrew-sass

A Homebrew tap for Sass
Ruby
35
star
20

embedded-protocol

A protocol for communicating between a Sass implementation and a host language
31
star
21

perl-libsass

Perl bindings for libsass (CSS::Sass)
Perl
29
star
22

sass-registry

Extension registry for Sass
Ruby
7
star
23

libsass.com

CSS
6
star
24

sass-site-built

The built HTML of the Sass website, used to see output diffs in code reviews
HTML
6
star
25

clone-linked-repo

A utility action that emits information about one PR linked from another's message
Shell
3
star