Skip to content

API Reference

Components

NameDescription
ColorPickerRoot.vueRoot wrapper that manages color state and provides context to all child components.
ColorPickerCanvas.vueA 2D gradient area for picking saturation and brightness/lightness by dragging a thumb. Supports HSV and HSL color models.
ColorPickerEyeDropper.vueA button that opens the native browser eye dropper to sample any color from the screen. Only rendered when the EyeDropper API is available.
ColorPickerInputHex.vueA text input group for editing the color in hexadecimal format, with an optional opacity field.
ColorPickerInputHSB.vueA text input group for editing Hue (0–360), Saturation (0–100), and Brightness (0–100) channels.
ColorPickerInputHSL.vueA text input group for editing Hue (0–360), Saturation (0–100), and Lightness (0–100) channels.
ColorPickerInputRGB.vueA text input group for editing the Red, Green, and Blue channels individually (0–255).
ColorPickerSliderAlpha.vueA slider for controlling the opacity (alpha) of the current color.
ColorPickerSliderRed.vueA slider for controlling the Red channel of the current color (0–255).
ColorPickerSliderGreen.vueA slider for controlling the Green channel of the current color (0–255).
ColorPickerSliderBlue.vueA slider for controlling the Blue channel of the current color (0–255).
ColorPickerSliderHue.vueA slider for selecting the hue angle across the full color spectrum (0–360°).
ColorPickerSliderSaturation.vueA slider for controlling the HSL saturation of the current color.
ColorPickerSliderLightness.vueA slider for controlling the HSL lightness of the current color.
ColorPickerSwatch.vueA small color chip that displays a preset color. Clicking it can be used to apply that color.

ColorPickerRoot.vue

The root component. Must wrap all other Vuelor components. It owns the color state and broadcasts it via Vue's provide/inject.

PropDefaultDescription
modelValue-Current color value. Accepts null, a formatted string, or a ColorObject.
defaultValue#B63DDAFFInitial color used when modelValue is null.
formathexaControls the shape of modelValue and both emitted events. See the Format table below.
stylingtailwindcsstailwindcss — uses built-in Tailwind classes. vanillacss — uses plain CSS class names. unstyled — strips all base styles.
disabledfalseDisables all interaction across every child component.
class-Extra classes applied to the root <div>.
ui-Override styles for any slot across all child components. See ThemeSlots.
EmitDescription
update:modelValueFires on every color change. The value shape matches the active format.
valueCommitFires once the user finishes an interaction (pointer up, input blur). Use this to save the value without flooding your store.

Format

The format prop determines the string representation emitted by update:modelValue and valueCommit. Formats that include alpha (hexa, rgba, hsla, hsva, object) also enable the opacity field in input components.

ValueExample outputAlpha
hex#B63DDANo
hexa#B63DDAFFYes
rgbrgb(182, 61, 218)No
rgbargba(182, 61, 218, 1.00)Yes
hslhsl(287, 63.8%, 54.7%)No
hslahsla(287, 63.8%, 54.7%, 1.00)Yes
hsvhsv(287, 72.0%, 85.5%)No
hsvahsva(287, 72.0%, 85.5%, 1.00)Yes
object{ rgb, rgba, hsl, hsla, hsv, hsva, hex, hexa } — see ColorObjectYes

Exposed: color

Access the live color state directly via a template ref. This is useful for reading values, setting colors programmatically, or building custom controls.

vue
<script setup>
import { useTemplateRef } from 'vue'
import { ColorPickerRoot } from '@vuelor/picker'

const picker = useTemplateRef('picker')

// Set color directly, bypassing v-model
function applyPreset(hexa) {
  picker.value.color.hexa.value = hexa
}
</script>

<template>
  <ColorPickerRoot ref="picker" v-model="color">
    ...
  </ColorPickerRoot>
</template>
PropertyTypeDescription
color.hexRef<string>Hex string without alpha (e.g. #B63DDA). Settable.
color.hexaRef<string>Hex string with alpha (e.g. #B63DDAFF). Settable.
color.rgbRef<RGB>RGB object { r, g, b }. Settable.
color.rgbaRef<RGBA>RGBA object { r, g, b, a }. Settable.
color.hslRef<HSL>HSL object { h, s, l }. Settable.
color.hslaRef<HSLA>HSLA object { h, s, l, a }. Settable.
color.hsvRef<HSV>HSV object { h, s, v }. Settable.
color.hsvaRef<HSVA>HSVA object { h, s, v, a }. Settable.
color.alphaRef<number>Alpha as an integer percentage, 0–100. Settable.

ColorObject

The shape of modelValue when format="object".

ts
type ColorObject = {
  rgb:  { r: number, g: number, b: number }
  rgba: { r: number, g: number, b: number, a: number }
  hsl:  { h: number, s: number, l: number }
  hsla: { h: number, s: number, l: number, a: number }
  hsv:  { h: number, s: number, v: number }
  hsva: { h: number, s: number, v: number, a: number }
  hex:  string   // e.g. "#B63DDA"
  hexa: string   // e.g. "#B63DDAFF"
}

ThemeSlots

Passed to the ui prop of ColorPickerRoot to override styles globally across all child components. Any slot can also be overridden locally on the child component's own ui prop.

ts
type ThemeSlots = {
  picker: {
    root: string        // The root <div> of ColorPickerRoot
  },
  dropper: {
    root: string        // The EyeDropper button
  },
  shared: {
    thumb: string       // Applied to thumbs in both Canvas and all Sliders
  },
  canvas: {
    root: string        // The Canvas gradient area
  },
  slider: {
    root: string        // The Slider wrapper
    track: string       // The Slider track (coloured bar)
  },
  input: {
    group: string       // The outer wrapper of any Input component
    item: string        // Each individual channel cell
    label: string       // The channel label (R, G, B, H, etc.)
    field: string       // The <input> element
  },
  swatch: {
    root: string        // The Swatch button
    alpha: string       // The alpha overlay strip inside the Swatch
  }
}

ColorPickerEyeDropper.vue

Opens the browser's native EyeDropper API. The component is not rendered at all when the API is unavailable (e.g. Firefox, Safari), so you don't need to add a v-if yourself — but you should plan your layout accordingly.

PropDefaultDescription
asbuttonThe HTML element or component to render as.
asChildfalseWhen true, merges all props and event listeners onto the first child element instead of rendering a wrapper.
class-Extra classes applied to the element.

Slots: Default slot — place any icon or label inside the button.

ColorPickerCanvas.vue

A 2-dimensional picking area. Dragging the thumb changes saturation on the X axis and brightness (HSV) or lightness (HSL) on the Y axis.

PropDefaultDescription
typeHSVColor model for the gradient. HSV renders a white→hue + top→black gradient. HSL renders a white→hue→black gradient matching the HSL lightness axis. Match this to your active input component: use HSL alongside ColorPickerInputHSL, and HSV alongside ColorPickerInputHSB.
wheeltrueWhen true, scrolling the mouse wheel over the canvas adjusts the hue.
class-Extra classes applied to the root element.
ui-{ root?: string, thumb?: string }

Keyboard interaction

When the canvas element is focused, the following keyboard shortcuts are active:

KeyAction
/ Decrease / increase saturation by 1%
/ Increase / decrease brightness or lightness by 1%
Shift + any arrow keySame as above but in 10% steps

ColorPickerInputHex.vue

An input group that exposes the color as a hex string (#RRGGBB) with an optional opacity field (when the active format includes alpha).

By default the component is uncontrolled — it reads from and writes to the picker context automatically. Pass v-model to take control of the value yourself (e.g. to render multiple independent pickers using the same input component).

PropDefaultDescription
modelValue-Optional. When provided, the component operates in controlled mode and emits update:modelValue instead of writing to the picker context.
class-Extra classes applied to the input group wrapper.
ui-Partial<{ group, item, label, field }> — overrides individual input slots.
EmitDescription
update:modelValueEmitted only in controlled mode, with the new hexa value.

Slots:

NameDescription
beforeRendered before the hex # label inside the first cell. Useful for embedding a ColorPickerSwatch as a preview chip.
vue
<ColorPickerInputHex>
  <template #before>
    <ColorPickerSwatch :value="color" />
  </template>
</ColorPickerInputHex>

ColorPickerInput*.vue

Shared props for ColorPickerInputHSB, ColorPickerInputHSL, and ColorPickerInputRGB.

All input components update only on blur (not on every keystroke). Invalid values are silently discarded and the field resets to its last valid state.

The opacity field is rendered automatically when the active format includes alpha (rgba, hsla, hsva, object). There is no prop to control this; change the format on ColorPickerRoot instead.

PropDefaultDescription
class-Extra classes applied to the input group wrapper.
ui-Partial<{ group, item, label, field }> — overrides individual input slots.

ColorPickerSlider*.vue

Shared props for ColorPickerSliderAlpha, ColorPickerSliderRed, ColorPickerSliderGreen, ColorPickerSliderBlue, ColorPickerSliderSaturation, and ColorPickerSliderLightness.

PropDefaultDescription
orientationhorizontalhorizontal or vertical. When vertical, the track grows upward.
class-Extra classes applied to the slider root.
ui-Partial<{ root, track, thumb }> — overrides slider slots.

ColorPickerSliderHue.vue

Same props as ColorPickerSlider*.vue, plus:

PropDefaultDescription
invertedfalseReverses the slider direction. Useful when rendering a vertical slider where you want 0° at the top.
orientationhorizontalhorizontal or vertical.
class-Extra classes applied to the slider root.
ui-Partial<{ root, track, thumb }>

ColorPickerSwatch.vue

A compact color chip. The right half of the chip shows the transparency level — fully transparent colors display a checkerboard pattern there.

Clicking a swatch automatically applies its value to the picker and emits valueCommit. No manual wiring required.

PropDefaultDescription
value-The hex or hexa color string this swatch represents (e.g. #FF6900 or #FF690080).
asbuttonThe HTML element or component to render as.
class-Extra classes applied to the swatch.
ui-Partial<{ root, alpha }>root targets the chip itself; alpha targets the transparency overlay.
EmitDescription
selectEmitted after the color is applied, with the value string. Use this to run additional logic (e.g. saving recently used colors).
vue
<!-- Minimal — just works, no wiring needed -->
<ColorPickerSwatch value="#FF6900FF" />

<!-- With @select hook for side effects -->
<ColorPickerSwatch
  v-for="color in swatches"
  :value="color"
  @select="saveToRecents"
/>

Types

All types are exported from @vuelor/picker and can be imported directly.

ts
import type {
  Format,
  ColorObject,
  HSV, HSVA,
  HSL, HSLA,
  RGB, RGBA,
  Hex, Hexa,
  ColorPickerRootProps,
  ColorPickerRootEmits
} from '@vuelor/picker'
TypeDefinition
HSV{ h: number, s: number, v: number }
HSVAHSV & { a: number }
HSL{ h: number, s: number, l: number }
HSLAHSL & { a: number }
RGB{ r: number, g: number, b: number }
RGBARGB & { a: number }
Hexstring — e.g. #B63DDA
Hexastring — e.g. #B63DDAFF
Format'hex' | 'hexa' | 'rgb' | 'rgba' | 'hsl' | 'hsla' | 'hsv' | 'hsva' | 'object'
ColorObjectSee ColorObject above
ColorPickerRootPropsProps interface for ColorPickerRoot
ColorPickerRootEmitsEmits interface for ColorPickerRoot

Released under the MIT License.