Skip to main content

Compound variants

Compound variants let you apply extra classes only when a specific combination of variant values is active. They live in the compoundVariants array and are evaluated after all individual variant classes are resolved.

Basic usage

Each entry in compoundVariants is an object that specifies which variant values must match, plus the class (or className) to apply when all conditions are met:
components/button.ts

Using compound variants with boolean variants

Compound variants work with boolean variants too. The following example applies a hover class only when the button is not disabled:
components/button.ts

Targeting multiple values

You can pass an array of values to a compound variant condition. The compound variant will match if the current prop value is any item in that array:
components/button.ts
Array targeting is a clean alternative to writing duplicate compound variant entries — use it whenever two or more variant values should produce the same extra class.