Skip to content

Color Picker for Angular

AngularInputs

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. App-supplied preset and recent swatches, a screen eyedropper where the browser supports it, and an optional WCAG contrast hint against a background. Inline or in a popup. A Form control whose value is a hex string.

  • 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.

Behavior, design tokens, and limitations are described on the Color Picker page; this page covers the Angular API.

import { Component } from '@angular/core';
import type { ColorPickerValue } from '@absoluteui/components/color-picker';
import { AuiColorPicker } from '@absoluteui/angular/color-picker';
@Component({
selector: 'app-brand-color',
imports: [AuiColorPicker],
template: `<aui-color-picker label="Brand color" contrastWith="#ffffff" [presets]="presets" [(value)]="color"></aui-color-picker>`,
})
export class BrandColorComponent {
color: ColorPickerValue = '#2563eb';
readonly presets = ['#2563eb', '#16a34a', '#dc2626'];
}
Terminal window
npm install @absoluteui/angular @absoluteui/components @absoluteui/core @absoluteui/theme

Setup with provideAbsoluteUI() is covered in Getting started. Styles are included with the component.

import { AuiColorPicker } from '@absoluteui/angular/color-picker';

Defaults for every instance: provideAbsoluteUIConfig({ components: { colorPicker: { ... } } }) (see Configuration).

Class AuiColorPicker; template reference #ref="auiColorPicker".

Server rendering: Renders on the server; the browser re-creates it after hydration.

Angular forms: implements ControlValueAccessor and Validator; the form value is ColorPickerValue. Bind [formControl], formControlName, or [(ngModel)]; validation messages of the component report through the aui error key. See Forms.

Input Type Default Description
label string Required. Visible label (accessible name of the trigger or the value field).
hideLabel boolean false Visually hide the label.
description string Help text, referenced by aria-describedby.
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’.
validationTiming ValidationTiming 'blur' When validation messages appear.
locale string 'en-US' Locale of messages and value text.
Model Type Change output Description
[(value)] ColorPickerValue (valueChange) The value: [(value)] without forms; with Angular forms, bind the form control instead.
Output Payload Description
(valueInput) ColorPickerValueDetail The value changes while dragging, with a key, or on any commit: { value, validity }. Re-emits aui-input.
(changed) ColorPickerValueDetail The value was committed (pointer release, key, swatch, typed text, eyedropper, clear): { value, validity }. Re-emits aui-change.
(opened) null The popup opened. Re-emits aui-open.
(closed) null The popup closed. Re-emits aui-close.

Call them through a viewChild query or a template reference.

Method Description
show(): void Open the popup (popup mode).
hide(restoreFocus?: boolean | undefined): void Close the popup; focus returns to the trigger by default.
reportValidity(): boolean | undefined 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.

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.

The Angular component renders the framework-neutral component, so its keyboard support, roles, WCAG 2.2 criteria, budgets, and import cost apply unchanged: see Color Picker: Accessibility and performance.