When comparing Stylus vs Garden (Clojure), the Slant community recommends Stylus for most people. In the question“What are the best CSS preprocessors/postprocessors?” Stylus is ranked 2nd while Garden (Clojure) is ranked 8th. The most important reason people chose Stylus is:
Stylus has an extremely terse syntax. Colons, semicons and braces are all optional allowing you to write Stylus code however you want. hover-darken(percent) if @background &:hover background: darken(@background, percent) .test background: blue hover-darken(50%) The hierarchy is required to be whitespace indented which makes it easier to identify which parent selectors child selectors belong to.
Ranked in these QuestionsQuestion Ranking
Pro Clean syntax
Stylus has an extremely terse syntax. Colons, semicons and braces are all optional allowing you to write Stylus code however you want.
hover-darken(percent) if @background &:hover background: darken(@background, percent) .test background: blue hover-darken(50%)
The hierarchy is required to be whitespace indented which makes it easier to identify which parent selectors child selectors belong to.
Pro Powerful feature set
Not only does Stylus support all the features from Less and Sass, it provides features not found anywhere else:
- You can get properties from parents and pull them into children and/or mixins - if the property isn't found, it will bubble up until it finds a match
- Introspective API, where a CSS block can tell if it’s at root level or not and change its output based on this
- Splats - taking variable amount of arguments in as an array
- Automatically vendor prefixes @keyframes
- Pass a CSS literal block wherever you want
- Convert files to base64
Pro Transparent mixins
One of Stylus' distinguishing features is transparent mixins: reusuable, possibly dynamic styles that look exactly like native CSS properties. This is particularly useful for using future non-prefixed properties and having them transparently expand to their prefixed counterparts without any special, preprocessor-specific syntax.
Pro Easy to integrate in projects already using npm
Stylus runs on node.js which makes it very easy to integrate into your project if you're using npm.
Pro Awesome error reporting
Stylus has clear and detailed error reporting that includes stack traces and line numbers.
Pro Lots of mixin libraries
Nib is Stylus's answer to Compass, but with the advantage of transparent mixins.
Ride css add dozens of useful mixins to Stylus. Compatible with axis, nib and other mixins libraries.
Roots is a awesome toolkit that contains a CSS library for Stylus that provides the benefits of Nib and more. It is essentially a collection of mixins that add a variety of enhancements to the Stylus workflow.
Pro Powerful @extend support
@extend gives inheritance and unlike for other preprocessors, you can pass any CSS selector, not just classes.
Pro Easier to learn than some of its competitors
Pro Convert files to base64
Stylus can also convert files to base64 which provides the following advantages:
- Easier to maintain
- Gives you the cleanliness of a URL link resource as well the benefits of base64 encoding
- Reducing the number of requests
Pro Great documentation
Pro Can do rgba(#hex, alpha)
Pro Style webpages with a full programming language
With Garden, you have access to all the core features of a powerful programming language to build your scripts, including functions, variables, namespaces, and data manipulation like map merging or concatenation.
Pro Full-stack Clojure with ClojureScript for front-end + Clojure for backend
Garden finishes the full Clojure stack experience — you can have the entire codebase in a single language with ClojureScript on the front-end, Clojure on the backend, and Garden for CSS.
Pro Hot loading
Using the core Garden auto loader or the excellent Garden Gnome plugin, watch your style changes take effect in the browser as soon as you save the code — no reload required.
Pro Styles as data-nesting are obvious
Clojure is a data-oriented programming language with strong emphasis on simple, clear inline data structures. Garden models styles using these same structures, making the cascade visually obvious.
Pro Clean syntax
Other options listed include various pain-points like use of @ symbols or too much cruft; because Garden is just Clojure, and Clojure is a very well-designed language aimed to emphasize simplicity and positive developer experience (without semantic whitespace problems), you have the full benefit of a well-designed and general-purpose syntax.
Pro CSS-engine accessible from front-end
Because Garden is also Clojurescript friendly, this means that you can dynamically effect styles based on app state.
Con Not under active development
Development of stylus has stagnated, there are lots of known bugs and it does not work well newer features like CSS Grid or custom poperties. See https://github.com/stylus/stylus/issues
Con Ambiguous syntax
The Stylus syntax is very loose and that leads to ambiguity where some definitions can mean different things. For example, hashed objects cannot be used when you choose to omit colons in your definitions, because the dot notated object getters could also be a nested class selector. As a result, you lose being able to use hashed object getters if you decided to write Stylus without colons.
Con Not as popular as Less and Sass
Stylus is younger than both Less and Sass, and not yet at the same level of popularity. As a result, Stylus currently has a smaller and less active community than the two more popular options.
Con Inconsistent style/flavour in different projects
Due to having such a loose syntax, the coding style can vary between different Stylus projects, making it hard to apply styles from other projects that use a different syntax style — at least if you care for consistency.
Con Heavily reliant on whitespaces
Stylus relies heavily on whitespaces to separate and define code blocks. While this makes for a cleaner syntax, it's also easier to make mistakes when indenting stuff, especially when working with someone else's code where you don't use the same style of indentation.
Con Harder to apply shared styles
Because you are working in Clojure, you can't just paste in raw css style snippets shared elsewhere.