スウォッチグループSwatchGroupExperimental

Selectable color swatch group (single-select) with roving keyboard focus and disabled out-of-stock swatches, for product variant and theme pickers.

プレビュー

Props

表は横にスクロールできます
プロパティ初期値説明
optionsSwatchOption[]-Swatches: { value, label, color, disabled? }.
valuestring-Selected swatch value (controlled).
onValueChange(value: string) => void-Selection change handler.
size"sm" | "default" | "lg""default"Swatch size.
disallowEmptyboolean-Keep a selection — clicking the active swatch won't clear it.
classNamestring-Additional CSS class names.

Usage

import { SwatchGroup } from "@gunjo/ui"

const options = [
  { value: "ink", label: "Ink", color: "hsl(var(--foreground))" },
  { value: "primary", label: "Primary", color: "hsl(var(--primary))" },
  { value: "muted", label: "Muted (sold out)", color: "hsl(var(--muted))", disabled: true },
]

export function Example() {
  const [color, setColor] = React.useState("ink")
  return <SwatchGroup options={options} value={color} onValueChange={setColor} disallowEmpty />
}