Color picker
Color picker component with a saturation and brightness area, a hue bar, a hex field, presets, inline mode and keyboard support.
How to use it
Run npx @blossomui/react add color-picker, or copy src/components/UI/ColorPicker/ColorPicker.tsx into your React project and import it.
import { ColorPicker } from './components/ui/ColorPicker'Props
ColorPickerLabels
| Prop | Type | Description |
|---|---|---|
| choose (required) | string | Accessible name of the panel. |
| area (required) | string | Accessible name of the area that sets saturation and brightness. |
| hue (required) | string | |
| hex (required) | string |
ColorPickerProps
| Prop | Type | Description |
|---|---|---|
| labels | Partial<ColorPickerLabels> | Texts of the component. Pass only the ones you want to change, for example to translate it. |
| value | string | Controlled color as a hex string, for example `#f472b6`. Use together with `onChange`. |
| defaultValue | string | Initial color when the picker is not controlled. |
| onChange | (color: string) => void | Called with the color as `#rrggbb`. |
| label | string | |
| hint | string | Helper text shown under the field. |
| error | string | Error message. It is shown in red under the field. |
| presets | string[] | Ready-made colors shown under the picker. |
| inline | boolean | Show the panel in the page instead of in a popover opened by a field. |
| area | boolean | Show the area for saturation and brightness. Turn it off for a compact picker with only the hue bar, the hex field and the presets. |
| disabled | boolean |