Skip to content

VariationPicker

One choice among a product's colours or sizes. Image options for colours, text options for sizes.

In Figma: Product Variation Option (node 25:2751). In code: components/ui/variation-picker.tsx

Example

Størrelse
Farve
import { VariationPicker } from '@/components/ui/variation-picker';

<VariationPicker
  label="Størrelse"
  name="size"
  defaultValue="M"
  options={[{ value: 'S', label: 'S' }, { value: 'M', label: 'M' }, { value: 'L', label: 'L' }]}
/>

Props

PropTypeDefaultWhat it does
label (required)stringWhat is being chosen, such as "Størrelse". Read aloud, not shown.
name (required)stringThe form field name. One picker is one radio group.
options (required)VariationOption[]{ value, label, image?, disabled? }. With image it is a colour option, without it a text option.
valuestringThe chosen value. With onChange the picker is controlled.
defaultValuestringThe value chosen from the start, uncontrolled.
onChange(value: string) => voidCalled with the new value.

Do

  • Use one picker per choice: one for colour, one for size.
  • Give every image option a label with the colour's name.

Do not

  • Do not use it for navigation or filters.
  • Do not show a price or stock inside an option.

Accessibility

  • Each option is a native radio button in a fieldset: arrow keys move, a form posts the value.
  • The Figma state Open is rendered on hover.

Tokens it uses

  • color.neutral.0
  • color.neutral.50
  • color.neutral.500
  • color.neutral.900
  • space.seam
  • type.body.sm
  • component.variation-option.size
  • component.variation-option.padding
  • component.variation-option.radius