Skip to content

Variant Picker

InputMIT
View in Storybook

Single-select product-option swatches (grind, size, color) with selected + out-of-stock states.

bun add @otfdashkit/ui

Preview

Variant Picker
Loading Storybook preview…

Code

import { useState } from 'react'
import { VariantPicker } from '@otfdashkit/ui'

export function Example() {
  const [grind, setGrind] = useState('whole')
  return (
    <div className="w-[360px]">
      <VariantPicker
        label="Grind"
        value={grind}
        onValueChange={setGrind}
        options={[
          { value: 'whole', label: 'Whole bean' },
          { value: 'espresso', label: 'Espresso' },
          { value: 'filter', label: 'Filter' },
          { value: 'french', label: 'French press' },
        ]}
      />
    </div>
  )
}

Free with the SDK. This component ships in @otfdashkit/ui under the MIT license.

Props

Props declared in the VariantPicker source. Inherited HTML attributes are not listed.

PropTypeDefaultDescription
optionsrequiredVariantOption[]
defaultValuestring | (readonly string[] & string)Uncontrolled initial value.
labelstringGroup label, e.g. "Grind" or "Size".
onValueChange(value: string) => void
valuestringControlled selected value.