Skip to Content

Configuration

The create() function accepts an optional configuration object.

import { create } from 'nano-css'; const nano = create(config);

Options

OptionTypeDefaultDescription
pfxstring'_'Prefix added to all generated class and animation names
hfunctionHyperscript function from your virtual DOM library (e.g. React.createElement). Required for jsx(), style(), styled(), and component addons
shHTMLElementDOM style sheet element for re-hydrating server-rendered styles
verbosebooleanfalseEnable verbose console output in development mode

Examples

With React

import { createElement } from 'react'; import { create } from 'nano-css'; const nano = create({ pfx: 'my-company-', h: createElement, });

With Preact

import { h } from 'preact'; import { create } from 'nano-css'; const nano = create({ h: h, });

With Server-Side Rendering

const nano = create({ sh: typeof document === 'object' ? document.getElementById('nano-css') : null, });

Built-in API

The renderer object created by create() includes these properties out of the box (no addons required):

PropertyDescription
nano.put(selector, css, atrule?)Inject CSS by selector and CSS-like object
nano.putRaw(rawCss)Inject a raw CSS string
nano.rawAccumulated CSS string (useful for server-side rendering)
nano.clienttrue when running in a browser environment
nano.pfxThe configured class name prefix
Last updated on