Skip to main content

StyleX Variants

A first-class variant API for StyleX.

Typed, compile-time variants with predictable class and style merging for React design systems.

npm install @stylex-variants/core @stylexjs/stylex

Live recipe

Variants by default.

Define a recipe once, then keep every call site concise and type-safe.

button.styles.ts
const button = sxv({
base: styles.base,
variants: { tone: { primary: styles.primary } },
defaultVariants: { tone: "primary" },
});

Core concepts

Minimal by default. Powerful when you need it.

Variants

Declare variant, size and state once.

const button = sxv({
base: styles.base,
variants: { tone: { primary: styles.primary } },
});
Read the guide →