Myth is a preprocessor that lets you write pure CSS without having to worry about slow browser support, or even slow spec approval.
It's like a CSS polyfill.
The same syntax from the CSS spec, using the var() function.
:root {
--purple: #847AD1;
--large: 10px;
}
a {
color: var(--purple);
}
pre {
padding: var(--large);
}
a {
color: #847AD1;
}
pre {
padding: 10px;
}
The same syntax from the CSS spec, using the calc() function.
pre {
margin: calc(var(--large) * 2);
}
pre {
margin: 20px;
}
The same syntax from the CSS spec, using the color() function.
a {
color: var(--purple);
}
a:hover {
color: color(var(--purple) tint(20%));
}
a {
color: #847AD1;
}
a:hover {
color: rgb(157, 149, 218);
}
Prefixes for common browsers are automatically added, so you don't need worry.
a {
transition: color .2s;
}
a {
-webkit-transition: color .2s;
transition: color .2s;
}
$ npm install -g myth $ myth input.css output.css# Generated output.css from input.css
Check out the full API on GitHub.
Myth lets you write pure CSS while still giving you the benefits of tools like LESS and Sass. You can still use variables and math functions, just like you do in preprocessors. It's like a polyfill for future versions of the spec.
Some of the features in CSS require runtime calculations, which neither Myth nor preprocessors handle, but what Myth does is let you write your code today in the future syntax, so that your code is future-proof. When browsers finally support these features you won't need to rewrite anything, just remove Myth and start using the cascade!
Taking plain CSS as an input also means you can use Myth to re-process anyone else's CSS (or another preprocessor's output), adding the browser support you need, without having to re-write the code in a completely different syntax.
Myth is built with Rework so it's incredibly fast, and has a nice Javascript API in addition to the CLI.