These benefits are in addition to the more general benefits of using CSS-in-JS:
Since CSS-Zero has no runtime, it can be installed purely as a devDependency:
npm install css-zero --save-dev
The simplest way to run CSS-Zero in a React application is using our Babel Macro:
import {css, styled} from 'css-zero/macro';
For applications created using Create React App (which supports both Babel Macros and CSS Modules out-of-the-box), no further setup or configuration is needed.
For usage with other front-end frameworks, CSS-Zero can be set up with our babel-plugin.
The basic usage of CSS-Zero looks like this:
import {css, styles} from 'css-zero'; // Write your styles using the `css` tag const blue = css` color: blue; `; const base = css` color: red; font-size: 16px; `; // then use the `styles` helper to compose your styles and generate class names export default props => <div className={styles(base, props.isBlue && blue)} />; ↓ ↓ ↓ ↓ ↓ ↓ Compiles to ↓ ↓ ↓ ↓ ↓ ↓ export default props => <div className={(props.isBlue ? "x1vong5g" : "x1dqz7z3") + " " + "x1e4w2a9"} /> // along with a the following .zero.css file: .x1vong5g {color:blue} .x1dqz7z3 {color:red} .x1e4w2a9 {font-size:16px}
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4