You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

sass

Package Overview
Dependencies
Maintainers
0
Versions
256
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sass

Syntactically Awesome Stylesheets (compiles to css)


Version published
Weekly downloads
14M
decreased by-0.7%
Maintainers
0
Install size
100 kB
Created
Weekly downloads
 

Package description

What is sass?

The sass npm package is a preprocessor scripting language that is interpreted or compiled into Cascading Style Sheets (CSS). It enables developers to use variables, nested rules, mixins, functions, and more, which can help in writing CSS in a more structured and maintainable way.

What are sass's main functionalities?

Variables

Variables allow you to store values that you can reuse throughout your stylesheet.

$primary-color: #333;

body {
  color: $primary-color;
}

Nesting

Nesting enables you to nest your CSS selectors in a way that follows the same visual hierarchy of your HTML.

nav {
  ul {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  li { display: inline-block; }

  a {
    display: block;
    padding: 6px 12px;
    text-decoration: none;
  }
}

Partials and Import

Partials are Sass files named with a leading underscore. You can import these partials into other Sass files to modularize your CSS and help keep things easier to maintain.

// _reset.scss
html,
body,
ul,
ol {
  margin: 0;
  padding: 0;
}

// main.scss
@import 'reset';
body {
  font-family: sans-serif;
}

Mixins

Mixins allow you to define styles that can be reused throughout your stylesheet.

@mixin border-radius($radius) {
  -webkit-border-radius: $radius;
     -moz-border-radius: $radius;
      -ms-border-radius: $radius;
          border-radius: $radius;
}

.box { @include border-radius(10px); }

Extend/Inheritance

Extend/Inheritance lets you share a set of CSS properties from one selector to another.

.message {
  border: 1px solid #ccc;
  padding: 10px;
  color: #333;
}

.success {
  @extend .message;
  border-color: green;
}

Operators

Sass supports standard math operators like +, -, *, /, and %.

.container {
  width: 100%;
}
.article {
  width: 600px / 960px * 100%;
}

Other packages similar to sass

Readme

Source

Sass.js

JavaScript implementation of Sass. Great for node.js and other frameworks supporting the CommonJS module system.

Installation

Install the Kiwi package manager for nodejs and run:

  $ kiwi -v install sass

Usage

With sass.js in the load path you can then use:

var sass = require('sass')
sass.render('... string of sass ...')
// => '... string of css ...'

sass.collect('... string of sass ...')
// => { selectors: [...], variables: { ... }, mixins: { ... }}

Comments

// foo
body
  // bar
  a
    :color #fff
    

compiles to

body a {
  color: #fff;}
  

Variables

!red = #ff0000
body
  :color !red
  

and

red: #ff0000
body
  :color !red
 

compile to

body {
  color: #ff0000;}

Selector Continuations

a
  :color #fff
  &:hover
    :color #000
  &.active
    :background #888
    &:hover
      :color #fff
      

compiles to

a {
  color: #fff;}

a:hover {
  color: #000;}

a.active {
  background: #888;}

a.active:hover {
  color: #fff;}
  

Literal JavaScript

type: "solid"
size: 1
input
  :border { parseInt(size) + 1 }px {type} #000
  

compiles to

input {
  border: 2px "solid" #000;}
  

Property Expansion

div
  =border-radius 5px
  

compiles to

div {
  -webkit-border-radius: 5px;
  -moz-border-radius: 5px;}
  

Mixins

 +large
   :font-size 15px
 +striped
   tr
     :background #fff
     +large
     &:odd
       :background #000
 table
   +striped
   :border none
   

compiles to

table {
  border: none;}
table tr {
  background: #fff;}
table tr {
  font-size: 15px;}
table tr:odd {
  background: #000;}

Testing

Update Git submodules and execute: $ make test or $ node spec/node.js or $ jspec --node

More Information

License

(The MIT License)

Copyright (c) 2009 TJ Holowaychuk <tj@vision-media.ca>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Keywords

FAQs

Package last updated on 06 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc