We experimented with styling approaches for React a while ago and produced our solution — React Stylesheet[1], which we used for over an year in different React applications.
It also produces components out of style definitions directly:
let GreenBox = style('div', {
base: {
background: 'green'
}
})
Which you can use like any other React component later: <GreenBox />
As you can see the API is kinda similar but uses JS instead of CSS string. What
are advantages? The following:* Consistent syntax: you can use functions, variabls, mixins, w/o the need for interpolation `${...}`.
* Tooling. This is big one. You can make your stylesheets linted with ESLint and typesafe (!!!) with FlowType or TypeScript.
FlowType is supported out of the box, see [2]. Typesafe stylesheets is a huge win for productivity, I constantly catch typos and invalid values via Flow.
[1]: https://github.com/prometheusresearch/react-stylesheet/blob/... [2]: https://github.com/prometheusresearch/react-stylesheet/blob/...
EDIT: additions
Styles are compiled into CSS so :hover and friends work here.