components/SwatchPicker
import { … } from 'zidane-ui'ui/src/components/SwatchPicker.tsx
Components#
SwatchPickerComponent#
Renders swatches as a radio group, with a caption that names the swatch in view.
function SwatchPicker<T extends string>(props: SwatchPickerProps<T>): ElementType parameters
| Name | Type | Description |
|---|---|---|
| T | extends string |
Parameters
| Name | Type | Description |
|---|---|---|
| props | SwatchPickerProps<T> | Component props. |
Returns
ElementProps
| Name | Type | Default | Description |
|---|---|---|---|
| ariaLabel | string | Accessible name of the radio group. | |
| caption? | (option: Swatch<T>) => ReactNode | Formats the caption of a swatch. Defaults to its label. | |
| className? | string | Extra classes on the picker. | |
| columns? | 4 | 5 | 6 | 5 | Tiles per row, for |
| note? | ReactNode | A muted line under the caption, such as where the pick shows. | |
| onChange | (value: T) => void | Called with the value of the swatch picked by click or keyboard. | |
| options | readonly Swatch<T>[] | The swatches, in order. | |
| shape? | 'dot' | 'tile' | 'dot' |
|
| style? | CSSProperties | Inline styles on the root element, merged after the component's own. | |
| value | T | undefined | The value of the picked swatch. |
Interfaces#
SwatchInterface#
One swatch of a SwatchPicker.
interface Swatch<T extends string>Type parameters
| Name | Type | Description |
|---|---|---|
| T | extends string |
Properties
| Name | Type | Description |
|---|---|---|
| label | string | Name of the swatch: the caption and the accessible name. |
| swatch | ReactNode | What the swatch shows: a color that fills the dot, or an image for a tile. |
| value | T | The value reported to |
SwatchPickerPropsInterface#
Props for SwatchPicker.
interface SwatchPickerProps<T extends string>Type parameters
| Name | Type | Description |
|---|---|---|
| T | extends string |
Properties
| Name | Type | Default | Description |
|---|---|---|---|
| ariaLabel | string | Accessible name of the radio group. | |
| caption? | (option: Swatch<T>) => ReactNode | Formats the caption of a swatch. Defaults to its label. | |
| className? | string | Extra classes on the picker. | |
| columns? | 4 | 5 | 6 | 5 | Tiles per row, for |
| note? | ReactNode | A muted line under the caption, such as where the pick shows. | |
| onChange | (value: T) => void | Called with the value of the swatch picked by click or keyboard. | |
| options | readonly Swatch<T>[] | The swatches, in order. | |
| shape? | 'dot' | 'tile' | 'dot' |
|
| style? | CSSProperties | Inline styles on the root element, merged after the component's own. | |
| value | T | undefined | The value of the picked swatch. |