Skip to content
← Inventory

SwatchSelector

Row of selectable color/image swatches with controlled single selection. Shares the selected value, onValueChange, and size with its {@link SwatchSelectorItem} children through context.

Usage

import { Swatch, SwatchMore, SwatchSelector, SwatchSelectorItem } from "@desk/ui/components/swatch-selector";

Best practices

  • Pair SwatchSelector with SwatchSelectorItem children — it shares value/onValueChange/size through context, so items need no individual wiring.

  • Prefer SwatchGroup when the row is a single-choice form control needing radio roles + arrow-key navigation; SwatchSelector is the lighter, roles-free option.

  • Selection is controlled — pass value and update it from onValueChange; there is no internal fallback state to fall back on.

Props

Swatch

PropTypeDefaultDescription
colorstring

CSS color value (hex, rgb, hsl, etc.). If provided along with children, children render on top.

aria-labelstring

Defines a string value that labels the current element. Accessible label for screen readers.

value(required)string | (readonly string[] & string)

Unique value for this swatch

childrenimport("react").ReactNode

Custom content rendered inside the swatch (e.g., images).

sizeSwatchSize

Override size for this specific swatch.

unavailableboolean

Whether this option is unavailable (out of stock)

SwatchMore

PropTypeDefaultDescription
count(required)number

Number of additional swatches not shown; rendered as +{count}.

SwatchSelector

PropTypeDefaultDescription
valuestring

Value of the currently selected item (controlled single selection).

onValueChange(value: string) => void

Fired with the newly selected item's value when a swatch is clicked.

sizeSwatchSize

Swatch size, inherited by items via context unless they override it.

SwatchSelectorItem

PropTypeDefaultDescription
colorstring

CSS color value (hex, rgb, hsl, etc.). If provided along with children, children render on top.

aria-labelstring

Defines a string value that labels the current element. Accessible label for screen readers.

value(required)string | (readonly string[] & string)

Unique value for this swatch

childrenimport("react").ReactNode

Custom content rendered inside the swatch (e.g., images).

sizeSwatchSize

Override size for this specific swatch.

unavailableboolean

Whether this option is unavailable (out of stock)

Composition

Builds on

Swatch, Tooltip