Skip to content
← Inventory

VariantSelector

A flexible variant selector that supports both single and multiple selection modes. Renders card-style items that can display images or colors.

Sand
Stone
Terracotta
Oak

Usage

import { VariantSelector, VariantSelectorItem } from "@desk/ui/compositions/variant-selector";

Best practices

  • Fill it with VariantSelectorItem children — they read selection from context and call back through it; value/defaultValue matches each item's value.

  • mode is a discriminated prop: "single" renders a role="radiogroup" and gives onValueChange a string, "multiple" renders a <fieldset> and a string[] — keep value/defaultValue types matching the mode.

  • Use VariantSelector for image/colour swatch pickers; for a labelled icon-over-text option grid use IconCard, and for plain radio/checkbox lists use RadioGroup/Checkbox.

Props

VariantSelector

PropTypeDefaultDescription
childrenReactNode

Child elements

classNamestring

CSS class name

defaultValuestring | string[]

Initial value

mode(required)"single" | "multiple"

Component mode

onValueChange((value: string) => void) | ((value: string[]) => void)

Value change handler

valuestring | string[]

Current value

VariantSelectorItem

PropTypeDefaultDescription
classNamestring

CSS class name

colorstring

Color value

disabledboolean

Whether disabled (blocks interaction)

highlightedboolean

Whether this option is highlighted (compatible with a hovered unavailable option)

imageReactNode
label(required)string

Label text

onMouseEnter() => void

Called when mouse enters this item

onMouseLeave() => void

Called when mouse leaves this item

unavailableboolean

Whether unavailable (visual styling only, still clickable)

value(required)string

Current value

Composition