Basic Variants
Each variant has a name and a set of options. Each option defines props to apply.Boolean Variants
For toggle-style variants, just definetrue. You don’t need false: {}.
⚠️ Avoid naming variants after existing component props. Use
isDisabled instead of disabled to prevent shadowing native props.With context, you can use the special
["boolean"] syntax to get proper boolean type inference. See Context for details.Default Variants
Set sensible defaults so users don’t have to specify everything.Compound Variants
Sometimes a specific combination of variants needs special styling. That’s whatcompoundVariants is for.
When to Use Compound Variants
✅ Use compound variants when:- Two variants interact visually - like
variantandcolordetermining background AND text color together - Specific combinations need exceptions - like adding a shadow only for large primary buttons
- You want to avoid CSS conflicts - compound variants let you be explicit about combinations
Multiple Compound Variants
You can define multiple compound variants that apply simultaneously.tailwind-merge.
Variant Props vs Component Props
Variant props are removed before being passed to the underlying component. Only “real” props reach the DOM.Next: Context
Learn how variants propagate from parent to child