Today I learned

Easy color computations using Sass & Stylus CLI

Use stylus's CLI for easy color computations. Stylus CLI is faster than Sass and has shorter syntax for color computations.

$ npm i -g stylus
$ stylus -i

Here's lighten and hue shift:

> #aaa + 10%
=> #b2b2b2

> #ff0 - 10deg
=> #ffd500

One-liner version

Not quite as elegant, but it can be useful.

echo "*{a: #ff0 - 10deg}" | stylus -p
* { a: #ffd500; }

Using Sass

If you need Sass for some reason, it also takes -i.

$ gem install sass
$ sass -i
>> darken(red, 10%)

You have just read Easy color computations using Sass & Stylus CLI, written on March 03, 2015. This is Today I Learned, a collection of random tidbits I've learned through my day-to-day web development work. I'm Rico Sta. Cruz, @rstacruz on GitHub (and Twitter!).

← More articles