Skip to content

Color Picker

A color editor with an area, sliders, and text input.

Anatomy

  • #default: Replace the inner controls. The group and hidden form input remain.
  • #area: Replace the two-axis area.
  • #hue: Replace the hue slider.
  • #alpha: Replace the opacity slider.
  • #field: Replace the color text input.
  • #preview: Replace the selected-color preview.
  • #swatches: Replace the optional preset palette.

Usage

Popover composition

Use Popover to show the picker in a popup.

Output format

Choose the format for the returned color. Hue stays editable for gray and black.

Red
Orange
Yellow
Green
Blue
Indigo
Purple
Unavailable gray
oklch(0.65 0.2 250 / 0.8)

Committed: No interaction yet

Read-only and disabled

These states retain the chosen value and prevent edits.

Examples

Output format

Choose the format for v-model. You can still change hue when the selected color is gray or black.

vue
<Dialog
  :ui="{
    overlay: 'fixed inset-0 bg-black/50 backdrop-blur-sm',
    content: 'bg-white rounded-xl shadow-xl w-full max-w-md',
    header: 'flex items-center justify-between p-6 border-b',
    body: 'p-6',
    footer: 'flex justify-end gap-2 p-6 border-t',
  }"
>

Popover composition

Put the picker in Popover's #content slot and its button in #trigger. Use separate models for the popup's open state and the color.

vue
import './main.css'

Read-only and disabled

These states retain the chosen value and prevent edits.

vue
<template>
  <Accordion
    :items="items"
    type="multiple"
  />
</template>

See the live demo's code for the state and style objects used in these examples.

Formats

Set format to choose the returned color string. It does not change which colors you can enter or which channels you edit. See supported formats. Changing the format keeps opacity and emits value-change with reason format. HEX uses eight digits for transparent colors; hexa uses eight digits for all colors.

HEX and RGB can lose colors outside sRGB. The control keeps the original color until you replace the model or enter a new value. Area and slider previews use sRGB. See precision and gamut for details.

Use a color value such as #56d799 or oklch(0.65 0.2 250). CSS variables, currentColor, and relative color expressions are not supported.

Behavior

The picker renders inline. Use Popover to show it in a popup. Its controls share one color, including hue changes while the value is black or gray.

ColorArea, ColorSlider, and ColorField in a picker slot share its color and format when you omit their v-model. Adding a child model gives that control a separate color. Listen to the picker's value-change and value-commit events for shared changes. The picker submits one named form value; its default children do not submit extra values.

The default slot provides value, cssColor, format, isOutOfGamut, setValue(value), setChannels(space, changes), and getChannel(space, channel). Pass arguments when calling actions, for example @click="setValue('#ff0000')".

API Reference

Props

PropTypeDefaultPurpose
modelValuestring"#ff0000"Selected CSS color. Bind with v-model.
formatColorFormat"hex"Format for the returned and submitted color string.
id, namestringFrom FieldInput ID and form field name.
required, disabled, readOnly, invalidbooleanfalseNative validation and interaction states; disabled/required also inherit from Field.
ariaLabel, ariaLabelledby, ariaDescribedbystringFrom Field where applicableAccessible naming and description.
uiComponent UI object-Classes for the named parts below.
colorSpace"hsb" | "hsl" | "lch" | "oklch""hsb"Editing space; independent of output format.
showAlpha, showField, showPreviewbooleantrueShow or hide the default controls. Hiding alpha does not discard existing transparency.
itemsArray<string | ColorSwatchOption>[]Optional presets.
dir"ltr" | "rtl""ltr"Horizontal direction.

Emits

EventPayloadMeaning
update:modelValueSelected colorVue model update.
value-change(value, details)Runs before a change. Use details.cancel() to stop it. Includes reason and the native event when available.
value-commit(value, details)Runs when an interaction ends. Canceling it does not undo the value change.

Slots

  • #default: Replace the inner controls. The group and hidden form input remain.
  • #area: Replace the two-axis area.
  • #hue: Replace the hue slider.
  • #alpha: Replace the opacity slider.
  • #field: Replace the color text input.
  • #preview: Replace the selected-color preview.
  • #swatches: Replace the optional preset palette.

UI Options

KeyElement
rootOuter group
controlsSlider container
fieldsPreview and field row
inputVisually hidden input for form submission and validation
areaNested ColorAreaUi object
hueNested ColorSliderUi for hue
alphaNested ColorSliderUi for opacity
fieldNested ColorFieldUi object
previewNested ColorSwatchUi object
swatchesNested palette UI object

Styling Hooks

UI keyCSS classData attributes / semantics
rootakaza-color-pickerShared form flags; data-akaza-format
controlsakaza-color-picker-controls-
fieldsakaza-color-picker-fields-
inputakaza-color-picker-inputNative input attributes
areaSee Color AreaSee Color Area
hueSee Color SliderSee Color Slider
alphaSee Color SliderSee Color Slider
fieldSee Color FieldSee Color Field
previewSee Color SwatchSee Color Swatch
swatchesSee Color Swatch PickerSee Color Swatch Picker

Form state attributes: data-akaza-disabled, data-akaza-readonly, data-akaza-invalid, data-akaza-focused, data-akaza-touched, data-akaza-dirty, data-akaza-filled, and data-akaza-out-of-gamut. Each appears only when true.

Use class or ui.root to style the root. Use the other ui keys for inner parts. Set sizes, borders, and colors in your own styles.

Keyboard

KeyBehavior
Tab / Shift+TabMove between area axes, sliders, field, and optional palette.
Arrow, Page, Home/End keysFollow the keyboard rules of the focused child control.
Escape in the text fieldRestore a pending draft first. When no draft needs restoring, Escape can dismiss the surrounding Popover.

Parity Notes

ColorPicker combines the color controls in one component. Reka shows a picker built from separate color primitives. The supplied Base UI reference has no color picker component.

Edit this page on GitHub ↗