Skip to main content

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 define true. 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 what compoundVariants is for.
The compound variant applies only when all specified conditions match.

When to Use Compound Variants

✅ Use compound variants when:
  • Two variants interact visually - like variant and color determining 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
⚠️ Don’t overuse them. If every combination needs a compound variant, your design system might need restructuring.

Multiple Compound Variants

You can define multiple compound variants that apply simultaneously.
All matching compound variants apply. Class conflicts are resolved by tailwind-merge.

Variant Props vs Component Props

Variant props are removed before being passed to the underlying component. Only “real” props reach the DOM.
This means you can use any variant name without worrying about HTML attribute conflicts.

Next: Context

Learn how variants propagate from parent to child