Component docs
Loading
"use client";
import { SwatchGrid } from "@pixxl-tools/components";| Prop | Type | Default | Description |
|---|---|---|---|
items (required) | readonly SwatchGridItem[] | — | Items to render. |
onValueChange | (value: string) => void | — | Called with the new value (only when it changes). |
value | string | null | — | Selected swatch id (controlled); null for none. |
defaultValue | string | null | — | Selected id when uncontrolled. |
itemsrequiredreadonly SwatchGridItem[]
Items to render.
onValueChange(value: string) => void
Called with the new value (only when it changes).
valuestring | null
Selected swatch id (controlled); null for none.
defaultValuestring | null
Selected id when uncontrolled.
Other props are passed to the root element (HTMLAttributes<HTMLDivElement>), including className, style, id and aria-* attributes.
import { colors } from "@pixxl-tools/components/tokens";
const items = [
{ color: colors.accent, id: "accent", label: "Accent" },
{ color: colors.danger, id: "danger", label: "Danger" },
];
const [color, setColor] = useState<string | null>("accent");
<SwatchGrid aria-label="Fill color" items={items} value={color} onValueChange={setColor} />