Configuration
base
Props that always apply, regardless of variants.
className, style, event handlers, ARIA attributes, etc.
variants
Define your variant options. Each variant is a named group with multiple options.
defaultVariants
Set which variant values apply when not specified.
compoundVariants
Apply styles when specific variant combinations occur.
color="primary" AND variant="outline", the matching compound variant applies.
context
Connect to a shared context for variant propagation. See Context for details.
Props Merging
better-styled intelligently merges props from different sources.Priority Order
From lowest to highest priority:- 🥉
base - 🥈
variants - 🥈
compoundVariants - 🥇 Props passed directly to the component
className
Classes are merged usingtailwind-merge, which handles Tailwind conflicts intelligently.
style
Style objects are merged withObject.assign. Later values override earlier ones.
Event Handlers
Here’s something special: event handlers are composed, not overwritten.Works With Any Component
styled() works with HTML elements, React components, and React Native components.
TypeScript
Types are fully inferred. No manual typing needed.Next: Variants
Deep dive into the variant system