How to Install css-variants
How to Install css-variants
Section titled “How to Install css-variants”Run one of the following commands to install css-variants:
npm install css-variantspnpm add css-variantsyarn add css-variantsRequirements
Section titled “Requirements”- Node.js 14+ or any modern JavaScript runtime
- Zero dependencies required
ESM and CommonJS Support
Section titled “ESM and CommonJS Support”css-variants ships with dual ESM and CommonJS builds:
// ESMimport { cv, scv, sv, ssv, cx } from 'css-variants'
// CommonJSconst { cv, scv, sv, ssv, cx } = require('css-variants')What Functions Are Included?
Section titled “What Functions Are Included?”The package exports five functions:
| Export | Description |
|---|---|
cv | Class variants for single-element components |
scv | Slot class variants for multi-element components |
sv | Style variants for inline CSS styles |
ssv | Slot style variants for multi-element inline styles |
cx | Class name merger utility (like clsx) |
Next Steps
Section titled “Next Steps”Create your first variant with the Quick Start guide.