Use this file to discover all available pages before exploring further.
Although primarily designed for handling class names, at its core, cva is really just a fancy way of managing a string. This makes it useful in a variety of contexts beyond UI component libraries.
BEM
CVA maps naturally onto BEM (Block Element Modifier) naming conventions. Define your base block class and use modifier classes as variant values.
cva isn’t limited to class names — since it returns a plain string, you can use it to manage any variant-driven text output.
import { cva } from "class-variance-authority";const greeter = cva("Good morning!", { variants: { isLoggedIn: { true: "Here's a secret only logged in users can see", false: "Log in to find out more…", }, }, defaultVariants: { isLoggedIn: "false", },});greeter();// => "Good morning! Log in to find out more…"greeter({ isLoggedIn: "true" });// => "Good morning! Here's a secret only logged in users can see"