Form
ColorPicker
A swatch that opens a colour panel, with a value in hex, RGB or HSB and an optional opacity slider.
WAI-ARIA tested
Import
main.ts
import { ColorPicker } from '@vitral/vue';Popup
AccentValue: 6466f1
Inline
HSB, without the text box
HSB: {
"h": 330,
"s": 70,
"b": 90
}
Opacity
The value grows two hex digits. Drag the slider, or focus it and use the arrows; Shift moves in tens.
OverlayValue: 3366994d
Tint, as RGBValue: {
"r": 16,
"g": 185,
"b": 129,
"a": 0.35
}
Opacity, inline
The chequer is what transparent looks like: it sits under the slider's gradient, the preview and the swatch.
Disabled
API
Read from packages/vue/src/components/ColorPicker/types.ts, so it says what the component actually accepts.
Props
| Name | Type | Description |
|---|---|---|
| inline | boolean | Show the panel in place, without a swatch to open it. |
| format | 'hex' | 'rgb' | 'hsb' | What v-model holds: `'ff0000'` (the default), `{ r, g, b }` or `{ h, s, b }`. |
| defaultColor | string | The colour the panel starts on while the value is empty. Defaults to `'ff0000'`. |
| showInput | boolean | Show a text box for the hex value under the area. Defaults to true. |
| alpha | boolean | Offer an opacity slider, and carry the opacity in the value: eight hex digits, or an `a` beside the channels. Off by default, so a picker that was only ever asked for a colour goes on returning one. |
| disabled | boolean | — |
| placement | OverlayPlacement | — |
| appendTo | string | `'body'` (the default), `'self'` to render in place, or a selector. |
Plus pt, dt and unstyled from BaseProps, see pass-through and unstyled mode.
Emits
| Event | Payload | Description |
|---|---|---|
| change | event: { originalEvent: Event; value: ColorPickerValue } | The colour was changed by the reader: a key, the end of a drag, or a typed hex value. |
| show | — | — |
| hide | — | — |