Skip to content
ProLifetime access for $199, paid once, every future release included
Truffle UI

Variant Selector

ProNew

Color swatches that name the selected color, and size pills with a struck-through sold-out state, both as radio groups.

Installation

pnpm dlx shadcn@latest add @viewport/variant-selector

First time? Add the @viewport registry to components.json. Setup takes one minute.

Usage

The code behind the preview above comes with Truffle Pro.

Props

<SwatchPicker>

PropTypeDefault
label*string

What is being chosen, e.g. "Color". Shown above the swatches with the selected name.

—
options*Swatch[]—
value*string—
onValueChange*(value: string) => void—
classNamestring—

<OptionPicker>

PropTypeDefault
label*string

What is being chosen, e.g. "Size".

—
options*Option[]—
value*string—
onValueChange*(value: string) => void—
asideReact.ReactNode

A link beside the label, e.g. to a size guide.

—
classNamestring—

Accessibility

  • Radio groups: arrow keys move and select.
  • The selected color's name is written out, so the choice never depends on telling shades apart.
  • Sold-out options say so in their name and cannot be chosen.
  • Respects prefers-reduced-motion.