Overview
A comprehensive color picker component featuring support for multiple color formats (HSL, HSLA, RGB, RGBA, HEX), accessibility features with contrast ratio display, and customizable color swatches.Installation
This component requires the@uiw/color-convert package:
Usage
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 |
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 |
Types
ColorPickerValue
Credits
- Credits to kalix127 for porting this component
- Inspired by @uplusion23