Skip to main content

Signature

Parameters

ElementType
required
The base component to style. Can be:
  • HTML element string: "button", "div", "span"
  • React component: Link, Pressable
  • Another styled component
object
required
Configuration object with the following properties:

Config Properties

VariantProps<T>
Props that always apply, regardless of variants.
object
Variant definitions. Each key is a variant name, each value is an object mapping option names to props.
When using context, variants defined here but not in createStyledContext() become local variants. They work on this component but don’t propagate to children. See Local Variants.
object
Default values for variants when not specified.
array
Array of compound variant definitions. Each applies when all conditions match.
StyledContext
Context for variant propagation between parent and child components.

Returns

A React component with:
  • All props from the base component
  • Variant props based on your config
  • Automatic type inference

Examples

Basic

With Context

With React Native

⚠️ Use isDisabled instead of disabled to avoid shadowing Pressable’s native prop.

Boolean Variants

You only need to define true. The false case uses base styles by default.

Compound Variants

Props Merging Behavior

Priority order (lowest to highest):
  1. 🥉 base
  2. 🥈 variants
  3. 🥈 compoundVariants
  4. 🥇 Direct props

See Also