Skip to content

Color Area

A two-dimensional color selector.

Anatomy

  • #thumb: Custom visual thumb content. Receives value, x, and y. It is decorative; native range inputs retain keyboard semantics.

Usage

Hue and saturation

Choose hue and saturation in the area. Lightness includes black and white; Opacity controls transparency.

Current: #56d799

Output format

Choose the format for the returned value. The area still edits hue and saturation.

#56d799

RTL and disabled

RTL reverses the horizontal axis. Disabled areas remain visible without accepting edits.

Right-to-left
Disabled

Examples

Hue and saturation

Drag left or right to change hue, and up or down to change saturation. Use Lightness for black (0%) or white (100%), and Opacity for transparency. This example uses HSL; the default area uses HSB saturation and brightness.

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',
  }"
>

Put v-model and format on ColorPicker to share one color between the area and sliders. Leave the child controls without their own models. This keeps hue and saturation when you pass through black, white, or transparent. You can also use ColorArea on its own.

Output format

Choose the format for the returned value. Selecting OKLCH returns an oklch(...) string. The area still edits HSL hue and saturation.

vue
<template>
  <Avatar
    src="/avatar.jpg"
    alt="Jane Doe"
    text="JD"
    :delay-ms="300"
  />
</template>

RTL and disabled

RTL reverses the horizontal hue axis. The disabled example shows the area and both sliders but prevents editing.

vue
<Button
  :ui="{
    root: 'rounded-md bg-black px-3 py-2 text-white',
    spinner: 'size-4 animate-spin',
  }"
>
  Save
</Button>

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

Pass disabled to custom slot controls as shown above. To show keyboard focus on slider handles, use peer outline-none on ui.axis and peer-data-[akaza-focus-visible] classes on ui.thumb.

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.

Use colorSpace, xChannel, and yChannel to change what the area edits. You do not need to change these props to choose a different output format.

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 area has two native range inputs, one per axis, and one visible thumb. Drag to change both channels. Press Tab to focus each channel and use the keyboard to edit it. Disabled and read-only controls prevent changes.

Choose two different channels from the same color space, such as RGB red/green or OKLCH chroma/lightness. Unsupported or repeated channels disable the area. The preview uses sRGB, but the value can contain colors outside sRGB. Opacity stays unchanged unless you choose alpha as an axis.

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.
colorSpaceColorSpace"hsb"Editing space.
xChannel, yChannelColorChannel"saturation", "brightness"Distinct channels supported by the editing space.
xLabel, yLabelstringGenerated from channel namesNames for the two accessible sliders.
xName, yNamestring-Optional separate numeric channel form values.
stepnumberChannel defaultKeyboard increment.
dir"ltr" | "rtl""ltr"Reverse horizontal geometry and arrow 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

  • #thumb: Custom visual thumb content. Receives value, x, and y. It is decorative; native range inputs retain keyboard semantics.

UI Options

KeyElement
rootGroup and pointer surface
areaCanvas plane
thumbVisual thumb
xInputHorizontal keyboard control
yInputVertical keyboard control
inputForm input for the full color value

Styling Hooks

UI keyCSS classData attributes / semantics
rootakaza-color-areaShared form flags; data-akaza-dragging, data-akaza-color-space
areaakaza-color-area-areaaria-hidden
thumbakaza-color-area-thumbaria-hidden
xInputakaza-color-area-x-inputNative slider ARIA
yInputakaza-color-area-y-inputNative slider ARIA; vertical orientation
inputakaza-color-area-inputNative validation attributes

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.

The thumb exposes --akaza-color but does not force a background. Use ui.thumb: 'bg-white' for a white handle, or bg-[var(--akaza-color)] for a color-filled handle.

Keyboard

KeyBehavior
Tab / Shift+TabFocus each of the area's two named sliders. The composed examples then continue to Lightness and Opacity.
Arrow keysAdjust the focused channel; horizontal arrows reverse for the horizontal axis in RTL.
PageUp / PageDown, Shift+ArrowAdjust by ten steps.
Home / EndSet the focused channel to its editor minimum/maximum.

Parity Notes

ColorArea combines Reka's root, area, and thumb parts in one component. Use ui and #thumb to customize them. The supplied Base UI reference has no color area component.

Edit this page on GitHub ↗