nano-css
comes only with a single put()
addon pre-installed. However, it has
plenty more to chose from. Below is a list of addons shipped with nano-css
.
put()
— injects CSS styles given a selectorrule()
— injects CSS styles and returns a generated selectordrule()
— likerule()
, but allows to add on-the-fly overridessheet()
— collection ofrule()
s, lazy injects CSS styles only when useddsheet()
— likesheet()
, but allows to add on-the-fly overridesjsx()
— creates styling blocks for virtual DOM librariesuseStyles()
— addsstyles
as a second argument for your componentwithStyles()
— injectsstyles
prop into your componentdecorator
— provides@css
decorator for styling stateful React componentscomponent
— provides ReactComponent
class to inherit fromstyle()
— allows you to create styled componentsstyled()()
— better syntax for styled componentshyperstyle()
— creates styled hyperscripth
functionstable
— generates consistent class namesatoms
— CSS shorthands for better DXnesting
— better nesting featureskeyframes()
— adds@keyframes
supporthydrate()
— adds support for re-hydration on client sideprefixer
— auto-prefixes your styles with correct vendor prefixesstylis
— write CSS as stringsunitless
— automatically addspx
to styles!important
— adds!important
to all declarations:global
— allows emitting global stylesanimate/*
— collection of animation stylesreset/*
— collection of CSS resetsreset-font
— global styles for better fontgoogleFont()
— loads custom fonts from Google Fontslimit
— limits server-side style sheet sizeamp
— displays warnings and cleans up styles for AMP appsvirtual
— virtual CSS renderer, splits css rules in atomic declarationsspread
— returns an object with data attributes used as a selectorarray
— use arrays to specify multiple valuessnake
— chain styling rulestachyons
— use Tachyons for rule chainingrtl
— flips all styles RTL (right-to-left)extract
— allows extraction of CSS into external*.css
style sheetsourcemaps
— generates source maps in dev mode.units
— CSS units as JavaScript functions
All addons are in the nano-css/addon/
folder and are exported
as an addon
named export. Addon is simply a function that receives nano-css
renderer object
as a single argument.
When these docs mention that you need to install an addon, say xxx
, you simply import it
from the addon folder and apply to the nano renderer object:
import {addon as addonXXX} from 'nano-css/addon/xxx';
addonXXX(nano);
nano.xxx(/* ... */);
Here we install rule()
and atoms
addons:
import {create} from 'nano-css';
import {addon as addonRule} from 'nano-css/addon/rule';
import {addon as addonAtoms} from 'nano-css/addon/atoms';
const nano = create();
addonRule(nano);
addonAtoms(nano);