node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org ยป



Build CSS in Javascript!


var builder = require('css-builder');

var b = builder();

b.rule('', function() {
    b.rule('a', function() {
        b.rule('&.red', {backgroundColor: 'red'});
        b.rule('&.blue', {backgroundColor: 'blue'});


// =>
// { background-color: red; }
// { background-color: blue; }


  • append: function called to append CSS to buffer. If you override this, the builder's toString() function will always return an empty string.
  • builder: base builder object, to which attrib, attribs, rule and commit methods will be added. Defaults to empty object. Allows you to pass in your own object/prototype chain, possibly including macro functions for defining more complex rules.