Color Picker
Introduction
Section titled “Introduction”Picks a color through a saturation and brightness area, a hue slider, and an optional opacity slider, or by typing hex, rgb(), or hsl() text. Apps can supply preset and recent swatches with spoken names; a screen eyedropper appears where the browser has the EyeDropper API; an optional hint shows the WCAG contrast ratio against a background. The panel is inline or opens in a popup from a trigger button. ColorPicker is a Form control: its value is a hex string (#rrggbb, or #rrggbbaa with alpha) or null, and native forms receive a hidden input.
- Area, hue, and opacityA keyboard-operable 2D area with hue and optional opacity sliders that follow the reading direction.
- Typed valuesHex, rgb(), and hsl() text with validation; the value is always normalized hex.
- Swatches with namesApp-supplied presets and recent colors, each with a spoken name.
- Contrast hintThe WCAG contrast ratio against a background with an AA and AAA verdict.
- Eyedropper where availableFeature-detected screen color picking; the button is hidden where the browser lacks it.
- Popup or inlineA trigger with the current color opens a dialog, or the panel sits in the page.
Use it for
- Brand, theme, label, or calendar colors chosen freely by the user.
- Colors that must meet a contrast target against a known background (contrast hint).
Use something else for
- A small fixed set of colors: use Radio Group or Toggle Group with color names.
- Wide-gamut or print color spaces (Display P3, CMYK): the picker works in sRGB.
Anatomy
<div class="aui-field aui-color-picker aui-color-picker--popup"> <label class="aui-field__label" for="trigger">Brand color</label> <button class="aui-color-picker__trigger" aria-haspopup="dialog" aria-expanded="false" aria-labelledby="label text"> <span class="aui-color-picker__swatch" aria-hidden="true"></span><span class="aui-color-picker__trigger-text">#2563eb</span> </button> <div class="aui-color-picker__panel" role="dialog" popover="manual" aria-labelledby="label"> (role="group" inline) <div class="aui-color-picker__area"><div class="aui-color-picker__thumb" role="slider" aria-valuetext="Saturation 84%, brightness 92%"></div></div> <div class="aui-color-picker__slider--hue"><div role="slider" aria-label="Hue"></div></div> <div class="aui-color-picker__slider--alpha" hidden><div role="slider" aria-label="Opacity"></div></div> <div class="aui-color-picker__formats" role="group" aria-label="Color format"><button aria-pressed="true">HEX</button>...</div> <div class="aui-color-picker__row"><span class="aui-color-picker__preview"></span><input class="aui-color-picker__input"><button eyedropper><button clear></div> <div class="aui-color-picker__swatches" role="group" aria-label="Preset colors"><button aria-label="Blue" aria-pressed="true"></button>...</div> <div class="aui-color-picker__swatches" role="group" aria-label="Recent colors">...</div> </div> <div class="aui-field__description">help</div> <p class="aui-color-picker__contrast">Contrast 5.17:1 against #ffffff. Passes AA.</p> <div class="aui-field__error">error</div> <input type="hidden" name="brand"></div>Live example
Section titled “Live example”Use the bar above each frame to switch theme, density, direction, and locale.
Color Picker in the Personal preferences showcase
Section titled “Color Picker in the Personal preferences showcase”The part of the Personal preferences showcase that uses Color Picker. Change its options, use it with the keyboard, and watch the event log; the link in the frame opens the full showcase. The bar above the frame switches theme, density, direction, and locale.
Showcase source
// Preferences showcase: a personal settings page with the new form controls. An accent// color with swatches, a contrast hint, and the eyedropper where supported; a satisfaction rating// with half steps; team assignment between two searchable lists (with drag); a work location// cascader whose cities load from a simulated server; a mention comment box with @people and// #tags from a simulated directory; a masked phone number; and an acknowledgement signature.import { Cascader, type CascaderOption, type CascaderValue } from '@absoluteui/components/cascader';import { ColorPicker } from '@absoluteui/components/color-picker';import { MaskedInput, MASK_PRESETS } from '@absoluteui/components/masked-input';import { MentionInput, type MentionSuggestion } from '@absoluteui/components/mention-input';import { Rating } from '@absoluteui/components/rating';import { SignaturePad } from '@absoluteui/components/signature-pad';import { TransferList, type TransferListItem } from '@absoluteui/components/transfer-list';import { action, choice, createShowcase, hostIn, section, status, toggle, wait } from './kit.js';
const sc = createShowcase({ title: 'Personal preferences', description: 'Pick an accent color, rate onboarding, choose your team and location, leave a comment with mentions, and sign.', simulated: true,});
// Appearance: color.const appearance = section(sc, 'Appearance', ['color-picker']);const color = ColorPicker.create(hostIn(appearance), { label: 'Accent color', description: 'Used for your calendar entries and highlights.', value: '#2563eb', presets: [ { value: '#2563eb', label: 'Blue' }, { value: '#15803d', label: 'Green' }, { value: '#b45309', label: 'Amber' }, { value: '#b91c1c', label: 'Red' }, { value: '#7c3aed', label: 'Violet' }, ], recent: ['#0f766e', '#be185d'], contrastWith: '#ffffff', name: 'accent',});sc.listen(color.host, ['aui-change'], 'color');
// Feedback: rating.const feedback = section(sc, 'Feedback', ['rating']);const rating = Rating.create(hostIn(feedback), { label: 'How was your onboarding?', allowHalf: true, value: 4, labels: ['Poor', 'Fair', 'Good', 'Very good', 'Excellent'], name: 'onboarding',});sc.listen(rating.host, ['aui-change'], 'rating');Rating.create(hostIn(feedback), { label: 'Team average', value: 4.5, allowHalf: true, display: true, size: 'sm' });
// Team: transfer list over a realistic directory size.const team = section(sc, 'Team', ['transfer-list']);const FIRST = ['Ana', 'Ben', 'Chen', 'Divya', 'Elif', 'Farah', 'Goran', 'Hana', 'Ivan', 'Jun', 'Kofi', 'Lena', 'Mateo', 'Nora', 'Omar', 'Priya'];const LAST = ['Ruiz', 'Okafor', 'Wang', 'Iyer', 'Kaya', 'Haddad', 'Petrov', 'Sato', 'Novak', 'Kim', 'Mensah', 'Fischer', 'Silva', 'Berg', 'Aziz', 'Rao'];const people: TransferListItem[] = [];for (let i = 0; i < 240; i++) { const name = `${FIRST[i % FIRST.length] ?? ''} ${LAST[Math.floor(i / FIRST.length) % LAST.length] ?? ''}`; people.push({ value: `p${String(i)}`, label: name, description: ['Engineering', 'Finance', 'People', 'Sales'][i % 4] ?? '', ...(i % 37 === 5 ? { disabled: true } : {}) });}const transfer = TransferList.create(hostIn(team), { label: 'Project team', items: people, value: ['p1', 'p2'], draggable: true, maxSelected: 12, name: 'team' });sc.listen(transfer.host, ['aui-change'], 'team');
// Location: lazy cascader.const location = section(sc, 'Work location', ['cascader']);const CITIES: Record<string, string[]> = { 'de/by': ['Munich', 'Nuremberg', 'Augsburg'], 'de/be': ['Berlin'], 'in/ka': ['Bengaluru', 'Mysuru'], 'in/mh': ['Mumbai', 'Pune'], 'us/ca': ['San Francisco', 'Los Angeles', 'San Diego'], 'us/ny': ['New York', 'Buffalo'],};const places: CascaderOption[] = [ { value: 'de', label: 'Germany', children: [{ value: 'by', label: 'Bavaria' }, { value: 'be', label: 'Berlin' }] }, { value: 'in', label: 'India', children: [{ value: 'ka', label: 'Karnataka' }, { value: 'mh', label: 'Maharashtra' }] }, { value: 'us', label: 'United States', children: [{ value: 'ca', label: 'California' }, { value: 'ny', label: 'New York' }] },];const cascader = Cascader.create(hostIn(location), { label: 'Office', options: places, value: ['de', 'by', 'munich'], levelLabels: ['Country', 'State', 'City'], name: 'office', loadChildren: async (_option, { signal, path }) => { await wait(500, signal); sc.log('server answered', { path }); return (CITIES[path.join('/')] ?? []).map((city) => ({ value: city.toLowerCase().replace(/\s+/g, '-'), label: city, isLeaf: true })); },});sc.listen(cascader.host, ['aui-change'], 'cascader');
// Comment: mentions from a simulated directory.const comment = section(sc, 'Comment', ['mention-input']);const TAGS = ['onboarding', 'payroll', 'benefits', 'equipment', 'training'];const findPeople = async (query: string, signal: AbortSignal): Promise<MentionSuggestion[]> => { await wait(250, signal); const q = query.toLowerCase(); return people.filter((p) => p.label.toLowerCase().includes(q)).slice(0, 8).map((p) => ({ id: p.value, label: p.label, description: p.description ?? '' }));};const mention = MentionInput.create(hostIn(comment), { label: 'Note for your manager', description: 'Type @ to mention a colleague or # to add a topic.', maxLength: 500, showCounter: true, name: 'note', triggers: [ { char: '@', label: '@ for people', provider: (query, { signal }) => findPeople(query, signal) }, { char: '#', label: '# for topics', provider: async (query, { signal }) => { await wait(150, signal); return TAGS.filter((t) => t.startsWith(query.toLowerCase())).map((t) => ({ id: t, label: t })); } }, ],});sc.listen(mention.host, ['aui-change', 'aui-mention'], 'mention');
// Contact: masked phone number.const contact = section(sc, 'Contact', ['masked-input']);const phone = MaskedInput.create(hostIn(contact), { label: 'Mobile phone', name: 'phone', ...MASK_PRESETS.phoneUs });sc.listen(phone.host, ['aui-change'], 'phone');
// Acknowledgement: signature.const sign = section(sc, 'Acknowledgement', ['signature-pad']);const signature = SignaturePad.create(hostIn(sign), { label: 'Signature', description: 'Draw your signature, or choose Type to enter your full name.', required: true, name: 'signature' });sc.listen(signature.host, ['aui-change'], 'signature');const summary = status(sign);const summarize = (): void => { const v = signature.value; summary.textContent = v === null ? 'Not signed yet.' : v.mode === 'type' ? `Signed as ${v.text}.` : `Signed with ${String(v.strokes.length)} strokes.`;};signature.host.addEventListener('aui-change', summarize);summarize();
// Options.const controls = [color, rating, transfer, cascader, mention, phone, signature];toggle(sc, 'Disabled', false, (disabled) => { for (const c of controls) c.update({ disabled });});toggle(sc, 'Read-only', false, (readOnly) => { for (const c of controls) c.update({ readOnly });});choice( sc, 'Color picker', [ { value: 'popup', label: 'Popup' }, { value: 'inline', label: 'Inline' }, ], 'popup', (mode) => { color.update({ mode }); }, ['color-picker'],);toggle(sc, 'Half stars', true, (allowHalf) => { rating.update({ allowHalf });}, ['rating']);/** A single path (strings), as opposed to a list of paths. */const isPath = (v: CascaderValue): v is readonly string[] => v?.every((part) => typeof part === 'string') === true;toggle(sc, 'Several offices', false, (multiple) => { const current = cascader.value; cascader.update({ multiple, value: multiple ? (isPath(current) ? [current] : []) : null });}, ['cascader']);action(sc, 'Validate', () => { const invalid = controls.filter((c) => !c.reportValidity()); sc.log('validate', { invalid: invalid.map((c) => c.label) });});action(sc, 'Reset', () => { for (const c of controls) c.reset(); summarize(); sc.log('reset');});Popup with presets and a contrast hint
Section titled “Popup with presets and a contrast hint”import { ColorPicker, type ColorPickerValueDetail } from '@absoluteui/components/color-picker';
const host = document.createElement('div');document.body.append(host);ColorPicker.create(host, { label: 'Brand color', name: 'brand', value: '#2563eb', required: true, contrastWith: '#ffffff', presets: [ { value: '#2563eb', label: 'Blue' }, { value: '#16a34a', label: 'Green' }, { value: '#dc2626', label: 'Red' }, ],});host.addEventListener('aui-change', (event) => { const { value } = (event as CustomEvent<ColorPickerValueDetail>).detail; if (value !== null) document.documentElement.style.setProperty('--brand', value);});Inline with opacity and recent colors
Section titled “Inline with opacity and recent colors”import { ColorPicker } from '@absoluteui/components/color-picker';
const host = document.createElement('div');document.body.append(host);const recent: string[] = ['#0f172a', '#f59e0b80'];const picker = ColorPicker.create(host, { label: 'Overlay', mode: 'inline', alpha: true, value: '#0f172acc', recent, format: 'rgb' });host.addEventListener('aui-change', () => { const value = picker.value; if (value !== null && !recent.includes(value)) { recent.unshift(value); picker.update({ recent: recent.slice(0, 8) }); }});Install and start
Section titled “Install and start”npm install @absoluteui/components @absoluteui/core @absoluteui/themeRegistry setup, the theme stylesheet, and the Content Security Policy are covered in Installation.
import { ColorPicker } from '@absoluteui/components/color-picker';import '@absoluteui/components/color-picker/style.css';First use
Section titled “First use”import { ColorPicker } from '@absoluteui/components/color-picker';import '@absoluteui/components/color-picker/style.css';
const host = document.querySelector<HTMLElement>('#theme-accent');if (host) ColorPicker.create(host, { label: 'Accent', mode: 'inline', alpha: true, value: '#2563ebcc' });More usage
import { ColorPicker, type ColorPickerValueDetail } from '@absoluteui/components/color-picker';
const host = document.querySelector<HTMLElement>('#label-color');if (host) { ColorPicker.create(host, { label: 'Label color', value: '#16a34a', contrastWith: '#ffffff', presets: ['#16a34a', '#2563eb', '#dc2626'] }); host.addEventListener('aui-change', (event) => { const { value } = (event as CustomEvent<ColorPickerValueDetail>).detail; console.log('saved color', value); });}Using Angular? See Color Picker for Angular.
API reference
Section titled “API reference”Factory
Section titled “Factory”ColorPicker.create(host: HTMLElement, options: ColorPickerOptions): ColorPickerGlobal configuration key: colorPicker (see Configuration).
Options
Section titled “Options”| Option | Type | Default | Description |
|---|---|---|---|
label |
string |
Visible label (accessible name of the trigger or the value field). Required. | |
hideLabel |
boolean |
"false" |
Visually hide the label. |
description |
string |
Help text, referenced by aria-describedby. | |
value |
ColorPickerValue |
"null" |
Initial color: hex, rgb(), or hsl() text (normalized to hex), or null. |
name |
string |
Form field name; a hidden input submits the hex value. | |
required |
boolean |
"false" |
A color must be chosen. |
disabled |
boolean |
"false" |
Disable the picker. |
readOnly |
boolean |
"false" |
Show the value without allowing changes (thumbs stay focusable). |
alpha |
boolean |
"false" |
Show the opacity slider; the value becomes #rrggbbaa. |
mode |
'popup' | 'inline' |
"popup" |
Popup from a trigger button, or the panel in place. |
presets |
readonly (string | ColorSwatch)[] |
App-supplied preset swatches with optional spoken names. | |
recent |
readonly (string | ColorSwatch)[] |
App-supplied recent colors (the app keeps the list). | |
eyeDropper |
boolean |
"true" |
Offer the screen eyedropper where the browser has the EyeDropper API. |
clearable |
boolean |
"!required" |
Show a clear button that sets the value to null. |
contrastWith |
string |
Background color for the WCAG contrast hint (ratio and AA/AAA verdict). | |
validate |
(value: string) => string | null |
Consumer validation of the hex value; return a message to mark it invalid. | |
icons |
Partial<ColorPickerIcons> |
Icons for the error, eyedropper, and clear button. | |
format |
ColorFormat |
"hex" |
Text format of the value field: ‘hex’, ‘rgb’, or ‘hsl’. Globally configurable. |
validationTiming |
'blur' | 'input' | 'submit' |
"blur" |
When validation messages appear. Globally configurable. |
locale |
string |
"en-US" |
Locale of messages and value text. Globally configurable. Inherited from common configuration. |
Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
host |
HTMLElement |
The host element. |
input |
HTMLInputElement |
The value text field. |
value |
ColorPickerValue |
The hex value, or null. |
open |
boolean |
Whether the popup is open. |
validity |
FieldValidity |
Current validity. |
options |
Readonly<ColorPickerOptions> |
Current options. |
Methods
Section titled “Methods”| Method | Description |
|---|---|
setValue(value: ColorPickerValue): void |
Set the value (color text or null; no event). Invalid text throws. |
show(): void |
Open the popup (popup mode). |
hide(restoreFocus?: boolean): void |
Close the popup; focus returns to the trigger by default. |
reportValidity(): boolean |
Show messages now and return validity. |
setCustomError(message: string | null): void |
Show or clear an external error. |
focus(): void |
Focus the trigger (popup) or the area thumb (inline). |
reset(): void |
Restore the initial value and clear validation state. |
update(options: Partial<ColorPickerOptions>): void |
Merge and apply options; an invalid update keeps the previous state. |
destroy(): void |
Close the popup, abort a running eyedropper, and remove rendering, listeners, and the form registration. |
Events
Section titled “Events”| Event | Detail | Bubbles | Cancelable | Description |
|---|---|---|---|---|
aui-input |
ColorPickerValueDetail |
Yes | No | The value changes while dragging, with a key, or on any commit: { value, validity }. |
aui-change |
ColorPickerValueDetail |
Yes | No | The value was committed (pointer release, key, swatch, typed text, eyedropper, clear): { value, validity }. |
aui-open |
null |
No | No | The popup opened. |
aui-close |
null |
No | No | The popup closed. |
CSS classes
Section titled “CSS classes”All rules live in the aui.components cascade layer, so application styles override them without specificity battles.
| Class | Purpose |
|---|---|
aui-color-picker |
Host (with aui-field). |
aui-color-picker--popup | --inline | --disabled | --readonly | --invalid | --empty |
State modifiers. |
aui-color-picker__trigger |
Popup trigger button. |
aui-color-picker__trigger-swatch | __trigger-text |
Trigger swatch and value text. |
aui-color-picker__panel |
Panel (dialog in the top layer, or group inline). |
aui-color-picker__area | __area-thumb |
Saturation and brightness area and its thumb. |
aui-color-picker__slider | --hue | --alpha | __slider-thumb |
Hue and opacity sliders. |
aui-color-picker__thumb |
Any thumb (role=slider). |
aui-color-picker__formats | __format |
Format buttons. |
aui-color-picker__row | __preview | __input |
Preview swatch and value field. |
aui-color-picker__icon-button | __eyedropper | __clear |
Eyedropper and clear buttons. |
aui-color-picker__swatches | __swatch | __swatch-button |
Preset and recent swatches. |
aui-color-picker__contrast |
Contrast hint (data-verdict: passAAA, passAA, passLarge, fail). |
Icon slots
Section titled “Icon slots”| Slot | Default icon |
|---|---|
error |
alert-circle |
eyeDropper |
locate |
clear |
close |
Design tokens
Section titled “Design tokens”Tokens this stylesheet reads (verified in CI). Override them in a theme or with the Theme Designer.
--aui-border-width | --aui-color-border | --aui-color-border-strong | --aui-color-disabled-bg | --aui-color-error-fg | --aui-color-focus-ring | --aui-color-hover | --aui-color-selected | --aui-color-selected-text | --aui-color-surface | --aui-color-surface-sunken | --aui-color-text | --aui-color-text-disabled | --aui-color-text-muted | --aui-control-height-md | --aui-control-height-sm | --aui-control-padding-x | --aui-duration-fast | --aui-easing-standard | --aui-focus-ring-offset | --aui-focus-ring-width | --aui-font-family-mono | --aui-font-family-sans | --aui-font-size-md | --aui-font-size-sm | --aui-font-size-xs | --aui-font-weight-medium | --aui-icon-size-sm | --aui-line-height-normal | --aui-line-height-tight | --aui-popover-max-height | --aui-radius-md | --aui-radius-pill | --aui-radius-sm | --aui-shadow-md | --aui-shadow-sm | --aui-space-1 | --aui-space-2 | --aui-space-3
TypeScript definitions
type ColorPickerValue = string | null;type ColorFormat = 'hex' | 'rgb' | 'hsl';interface ColorPickerConfig { validationTiming: 'blur' | 'input' | 'submit'; format: ColorFormat }interface ColorSwatch { value: string; label?: string }interface ColorPickerIcons { error: IconRef; eyeDropper: IconRef; clear: IconRef }interface ColorPickerOptions extends Partial<ColorPickerConfig> { label: string; hideLabel?: boolean; description?: string; value?: ColorPickerValue; name?: string; required?: boolean; disabled?: boolean; readOnly?: boolean; alpha?: boolean; mode?: 'popup' | 'inline'; presets?: readonly (string | ColorSwatch)[]; recent?: readonly (string | ColorSwatch)[]; eyeDropper?: boolean; clearable?: boolean; contrastWith?: string; validate?: (value: string) => string | null; locale?: string; icons?: Partial<ColorPickerIcons>;}interface ColorPickerValueDetail { value: ColorPickerValue; validity: FieldValidity }Accessibility and performance
Section titled “Accessibility and performance”Accessibility
Section titled “Accessibility”Pattern: WAI-ARIA APG Slider for hue and opacity; the saturation and brightness area is one role=slider thumb whose aria-valuetext names both values; the popup is a non-modal dialog opened by a button with aria-haspopup=dialog and aria-expanded.
Checked on every docs build: the showcase passes axe (WCAG 2.2 A and AA rules) in the default, dark, and high-contrast themes and right to left; the playground loads without errors and passes axe before and after every on/off option is switched, with no Content Security Policy violations.
Keyboard
Section titled “Keyboard”| Key | Context | Action |
|---|---|---|
| Enter / Space | Trigger | Open or close the popup; focus moves to the area. |
| Escape | Popup | Close the popup and return focus to the trigger. |
| ArrowRight / ArrowLeft | Area | Saturation up or down by 1% (mirrored in right-to-left); Shift moves 10%. |
| ArrowUp / ArrowDown | Area | Brightness up or down by 1%; Shift moves 10%. |
| Page Up / Page Down | Area | Brightness up or down by 10%. |
| Home / End | Area | Saturation 0% or 100%. |
| Arrow keys | Hue or opacity slider | One degree or 1% (Shift: 10); horizontal arrows follow the reading direction. |
| Page Up / Page Down | Hue or opacity slider | Ten degrees or 10%. |
| Home / End | Hue or opacity slider | Minimum or maximum. |
| Enter | Value field | Apply the typed color (invalid text shows an error and keeps the value). |
| Tab | Panel | Moves through area, sliders, formats, value field, eyedropper, clear, and swatches; leaving the popup closes it. |
| Element | Role |
|---|---|
| trigger (popup mode) | button (aria-haspopup=dialog, aria-expanded) |
| panel | dialog (popup) or group (inline), labelled by the field label |
| area thumb | slider |
| hue and opacity thumbs | slider |
| format buttons and swatches | button (aria-pressed) inside role=group |
ARIA attributes
Section titled “ARIA attributes”| Attribute | Element | Value |
|---|---|---|
aria-labelledby |
trigger | the label and the current value text |
aria-valuetext |
area thumb | ‘Saturation 80%, brightness 60%’ |
aria-valuenow / aria-valuemin / aria-valuemax |
thumbs | saturation 0-100, hue 0-359, opacity 0-100 |
aria-readonly |
thumbs | true when readOnly |
aria-disabled |
thumbs | true when disabled (also removed from the tab order) |
aria-pressed |
format buttons and swatches | the active format; the swatch matching the value |
aria-label |
swatches | the app’s name for the color, or its hex value |
aria-describedby |
trigger (popup) or value field (inline) | help text, contrast hint, and error |
aria-invalid |
trigger or value field | true while an error is shown |
Opening the popup focuses the area thumb; Escape and the trigger return focus to the trigger; pressing the area or a slider focuses its thumb.
WCAG 2.2 success criteria addressed
Section titled “WCAG 2.2 success criteria addressed”Automated test results: Accessibility and compliance.
Notes and known caveats
Section titled “Notes and known caveats”- Every pointer action has a keyboard alternative, and the typed value field is a non-dragging alternative (WCAG 2.5.7).
- Swatches carry spoken names (aria-label), so the color is not conveyed by color alone (WCAG 1.4.1).
- Clearing the color is announced through the shared live region.
- Manual screen-reader verification (NVDA, JAWS, VoiceOver) is pending.
- The browser’s eyedropper overlay is outside the component’s control; it is optional and the typed field is an alternative.
Performance
Section titled “Performance”| Import cost | Minified | gzip | brotli | CSS brotli |
|---|---|---|---|---|
@absoluteui/components/color-picker |
59.0 kB | 20.2 kB | 18.1 kB | 2.0 kB |
Measured at build time, including every AbsoluteUI module the component pulls in. No third-party runtime dependencies.
| Budget (enforced in CI) | Limit |
|---|---|
| ColorPicker.create, per instance | < 3 ms average in headless Chromium |
| Drag update (pointermove) | < 1 ms per event; only attributes and custom properties change |
Tested scale: Up to 64 preset and 16 recent swatches.
A drag move updates a few attributes and custom properties; swatches are rebuilt only on render. No layout is read except the pressed element’s rectangle during a drag.
Measured run times: Performance.
Details
Section titled “Details”States
Popup closed or open; inline; empty (no color); with opacity; read-only; disabled; invalid (required and empty, unparsable text, validate, custom error); dragging.
State transitions
| From | Trigger | To |
|---|---|---|
| popup closed | trigger click, Enter, or Space | open; focus on the area; aui-open |
| popup open | Escape or trigger | closed; focus on the trigger; aui-close |
| popup open | focus leaves the field and panel, or an outside press | closed |
| any | arrow, Page, Home, or End on a thumb | new value; aui-input and aui-change |
| any | press and drag on the area or a slider | aui-input per move; aui-change on release |
| dragging | pointer cancel | the value before the drag |
| any | valid text plus Enter or blur | new value; aui-change |
| any | unparsable text | error shown; the value is kept |
| any | swatch, eyedropper pick, clear | new value; aui-change |
Accessibility notes
- Every drag has a keyboard alternative, and typing a value is a non-dragging alternative (WCAG 2.5.7).
- Give swatches names (
{ value, label }) so colors are not conveyed by color alone (WCAG 1.4.1). - Thumbs and swatch buttons are 24 by 24 CSS pixels (WCAG 2.5.8).
- Clearing is announced; value changes are conveyed by the focused slider’s value text.
- The e2e axe run covers three themes; manual screen-reader verification is pending.
Responsive behavior
The panel is 16.5rem wide and never wider than its container; the popup is positioned and height-limited (it scrolls) by the positioning engine.
Right-to-left
Saturation and the hue and opacity sliders run along the reading direction: in right-to-left the gradients are mirrored and ArrowLeft increases. Brightness always runs bottom to top.
Theming
Surfaces, borders, focus rings, and the pressed format use theme tokens in all three themes. Thumbs have a white ring and a black outline so they are visible on any color. Forced colors draw thumbs with Canvas and CanvasText, swatches and tracks with a CanvasText border, and pressed items with Highlight.
Global configuration
configureAbsoluteUI({ components: { colorPicker: { format: 'rgb', validationTiming: 'input' } } });Component configuration
Instance format, validationTiming, and locale override configuration; the format buttons change the format for the instance until update({ format }). Configuration changes re-render existing pickers.
Icons
icons.error (default alert-circle), icons.eyeDropper (default locate; for an eyedropper glyph pass colorPickerIcon from @absoluteui/icons/set/color-picker), and icons.clear (default close).
Security
Labels, swatch names, and values use textContent and aria-label. All color input is parsed and normalized to hex before it reaches the CSSOM (style.setProperty), so strict CSP without unsafe-inline styles works and no CSS can be injected through a color.
Data handling
No persistence, network access, or telemetry. Recent colors are stored by the app. The eyedropper reads one pixel only after the user’s click and the browser’s own prompt; it is aborted on close and destroy.
Supported data scale
Up to 64 preset and 16 recent swatches are tested; larger lists work but make the panel scroll.
Edge cases
- Grays and black keep the previous hue (and black the previous saturation), so the thumbs do not jump.
- Without
alpha, typed or preset alpha is dropped; withalpha, the value always has eight hex digits. #abc,abc,rgb(1 2 3 / 50%),rgba(...),hsl(210deg 50% 40%), andhsla(...)are accepted.- Clearing the text and pressing Enter sets the value to
null(required pickers then report a missing value). - Without
EyeDropper(Firefox, Safari) the eyedropper button is not rendered; a cancelled pick changes nothing.
Errors
| Code | Category | Cause |
|---|---|---|
COLOR_PICKER_OPTIONS |
configuration | Blank label, unparsable value, contrastWith, or swatch, an unknown mode, or a non-function validate. |
CFG_INVALID_VALUE / CFG_UNKNOWN_OPTION |
configuration | Invalid configuration (for example an unknown format). |
Invalid options throw before the host is modified; an invalid update() leaves the previous state intact. Unparsable typed text is a validation error (“Enter a color such as #2563eb.”), not an exception.
Known limitations
- sRGB only, 8-bit hex values.
- The eyedropper exists only in browsers with the EyeDropper API (Chromium-based browsers); it is feature-detected.
- Manual screen-reader verification is pending.
Unsupported scenarios
- Wide-gamut values (Display P3, OKLCH).
- CSS color names such as
rebeccapurpleas typed input.
(c) 2026 Kasadara Technology Solutions Pvt Ltd. AbsoluteUI is free to use under the AbsoluteUI Free Use License; it is not open source.