Color Picker
A comprehensive color picker component with support for multiple color formats, accessibility features, and custom swatches.
Note: This component uses @uiw/color-convert
npm package for color conversions.
Install using CLI
Install Manually
API
ColorPicker Props
Prop Name | Type | Default | Description |
---|---|---|---|
value | string | HsvaColor | HslaColor | RgbaColor | undefined | The current color value in any supported format |
type | 'hsl' | 'hsla' | 'rgb' | 'rgba' | 'hex' | 'hsl' | Default color format to display in inputs |
swatches | HexColor[] | [] | Array of predefined color swatches |
hideContrastRatio | boolean | false | Hide the accessibility contrast ratio section |
hideDefaultSwatches | boolean | false | Hide the default color swatches |
class | string | "" | Additional CSS classes for the popover content |
open | boolean | false | Control the open/closed state of the color picker |
ColorPicker Events
Event Name | Type | Description |
---|---|---|
value-change | (value: ColorPickerValue) => void | Emitted when the selected color changes |
update:open | (value: boolean) => void | Emitted when the popover open state changes |
ColorPickerValue Type
Features
- Multiple color formats (HEX, HSL, HSLA, RGB, RGBA with alpha channel)
- Interactive saturation, hue, and alpha sliders
- Alpha channel support with transparency slider for RGBA/HSLA modes
- Custom color swatches with default predefined colors
- Accessibility contrast checker with AA/AAA indicators
Credits
- Credits to kalix127 for porting this component.
- Inspired by @uplusion23.