- Components
- Colors
- Color Swatch Picker
Color Swatch Picker
A ColorSwatchPicker displays a list of color swatches and allows a user to select one of them.
basic.tsx
Installation
npm
pnpm
yarn
bun
Anatomy
Controlled
controlled.tsx
Label
By default, ColorSwatchPicker
has an aria-label
with the localized string "Color swatches". This can be overridden with a more specific accessibility label using the aria-label
or aria-labelledb
y props. All labels should be localized.
Options
Disabled
disabled.tsx
API Reference
Prop | Type | Default | Description |
---|---|---|---|
children | ReactNode | - | The children of the component. |
layout | 'grid' | 'stack' | 'grid' | Whether the items are arranged in a stack or grid. |
value | string | Color | - | The current value (controlled). |
defaultValue | string | Color | - | The default value (uncontrolled). |
className | string | (values: ColorSwatchPickerRenderProps & {defaultClassName: string | undefined}) => string | - | The CSS className for the element. A function may be provided to compute the class based on component state. |
style | CSSProperties | (values: ColorSwatchPickerRenderProps & {defaultStyle: CSSProperties}) => CSSProperties | undefined | - | The inline style for the element. A function may be provided to compute the style based on component state. |
Event | Type | Description |
---|---|---|
onChange | (value: Color) => void | Handler that is called when the value changes. |
Last updated on 6/12/2024