Skip to content

css-variants is no longer maintained. Use @lynstack/class-recipe: faster, stricter types, and React Native support. Migrate →

No longer maintained. Migrate to class-recipe →

How to Install css-variants

Run one of the following commands to install css-variants:

Terminal window
npm install css-variants
  • Node.js 14+ or any modern JavaScript runtime
  • Zero dependencies required

css-variants ships with dual ESM and CommonJS builds:

// ESM
import { cv, scv, sv, ssv, cx } from 'css-variants'
// CommonJS
const { cv, scv, sv, ssv, cx } = require('css-variants')

The package exports five functions:

ExportDescription
cvClass variants for single-element components
scvSlot class variants for multi-element components
svStyle variants for inline CSS styles
ssvSlot style variants for multi-element inline styles
cxClass name merger utility (like clsx)

Create your first variant with the Quick Start guide.