API Reference
cva
Builds a cva
component
import { cva } from "cva";
const component = cva(options);
Parameters
options
base
: the base class name (string
,string[]
or otherclsx
value)variants
: your variants schemacompoundVariants
: variants based on a combination of previously defined variantsdefaultVariants
: set default values for previously defined variants.
Returns
A cva
component function
cx
Concatenates class names (an alias of clsx
)
const className = cx(classes);
Parameters
classes
: array of classes to be concatenated (seeclsx
usage)
Returns
string
compose
Shallow merges any number of cva
components into a single component.
import { compose } from "cva";
const composedComponent = compose(options);
Parameters
options
: array of cva
components
Returns
A cva
component function
defineConfig
Generate cva
, cx
and compose
functions based on your preferred configuration.
Store in a cva.config.ts
file, and import across your project.
import { cva } from "cva";
// cva.config.ts
export const { cva, cx, compose } = defineConfig(options);
options
hooks
onComplete
: returns a concatenated class string of all classes passed tocx
,cva
orcompose
.