Components
SwatchPicker
Controlled preset selector that picks one swatch from a fixed palette, with optional custom.
SwatchPicker presents a fixed palette of swatches and lets the user pick
one; it is controlled via value/onChange. It is domain-neutral — wire it to
whatever the swatch values represent in your app, such as a brand accent color.
Each swatch is a string or a { value, label } object; set allowCustom to add
a free-form entry and size ('sm' | 'md') to scale the chips.
Example
Preview
import { SwatchPicker } from '@officina/ui';
import { useState } from 'react';
function AccentSwatches() {
const [accent, setAccent] = useState('#3858e9');
return (
<SwatchPicker
value={accent}
onChange={setAccent}
allowCustom
swatches={['#3858e9', '#7c3aed', '#0ea5e9', '#16a34a', '#e11d48']}
/>
);
}API
| Prop | Type | Default | Description |
|---|---|---|---|
| onChange* | (value: string) => void | — | Called with the newly selected swatch value. |
| swatches* | (string | Swatch)[] | — | Selectable swatches — hex strings or `{ value, label }` objects. |
| value* | string | — | Currently selected swatch value (controlled). |
| allowCustom | boolean | false | Append a native color input for arbitrary values. |
| size | enum | md | Swatch size. Defaults to `'md'`. |