Color Picker

Free

HSV gradient canvas picker with hue rail, alpha channel, hex input, preset swatches and 3 sizes.

</>sv-color-picker colorpickerinput
import { SvColorPickerComponent } from '@styloviz/forms/color-picker';

Demo & usage

Basic usage

Usage example — open the gallery for the full interactive demo.

An interactive demo for this component lives in the gallery.

Open live demo

More examples

Alpha + preset swatches

example.htmlAngular
<sv-color-picker [showAlpha]="true" [swatches]="brandColors" format="hex" [(ngModel)]="color" />

Signal Forms

Bind it with `[formField]` from `@angular/forms/signals` — the control is a ControlValueAccessor, which Signal Forms drives on Angular 21 and 22 alike.

color-picker.signal-forms.tsTypeScript
import { ChangeDetectionStrategy, Component, signal } from '@angular/core';
import { FormField, form, pattern, required } from '@angular/forms/signals';
import { SvColorPickerComponent } from '@styloviz/forms/color-picker';

@Component({
  selector: 'app-color-picker-signal-forms',
  standalone: true,
  changeDetection: ChangeDetectionStrategy.OnPush,
  imports: [FormField, SvColorPickerComponent],
  template: `
    <sv-color-picker [formField]="brand.primary" label="Primary colour" />
    <p>Colour: {{ brand.primary().value() }} · valid: {{ brand.primary().valid() }}</p>
  `,
})
export class ColorPickerSignalFormsExample {
  readonly model = signal({ primary: '#3b82f6' });
  readonly brand = form(this.model, (path) => {
    required(path.primary);
    pattern(path.primary, /^#[0-9a-f]{6}$/i);
  });
}

When to use

  • Letting users pick an arbitrary color (theming, labels, calendars, design tools).
  • You need HSV selection plus hex entry and brand preset swatches.
  • For a fixed brand palette only, a swatch list or Select may suffice.

Async states

None — this component has nothing to load, so it has no loading, empty or error state to drive.

Inputs

NameTypeDefaultDescription
valuestring (two-way)'#3b82f6'Selected color (two-way).
formatColorPickerFormat'hex'Output format: hex, rgb or hsl.
sizeColorPickerSize'md'Picker size: sm, md or lg.
swatchesreadonly ColorSwatch[]defaultSwatches(this.labels)Preset swatch palette.
disabledbooleanfalseDisable the picker.
labelstring''Accessible label for the control.
showAlphabooleanfalseShow the alpha (transparency) channel.
contrastBackgroundstring''A background to check the chosen colour against.
colorNamer(hex: string) => string`svColorName`, in the app's `core` labelsTurn the hex into words for assistive tech.
errorMessagestring''Client-side validation message.
serverErrorSvServerErrornullA rejection reported by the server about this value. Self-expiring.

Outputs

EventPayload typeDescription
colorChangestringEmitted with the new color whenever it changes.
valueChangestringEmits the new `value` whenever it changes — the output half of `[(value)]`.

Customization & theming

  • HSV canvas with a hue rail and optional `showAlpha` opacity channel; `format` outputs hex, rgb or hsl.
  • Hex input plus configurable preset `swatches` ({ label, value }); `label`, `disabled`, three `size`s.
  • Two-way bind `[(value)]` or a reactive control (CVA); listen to `(colorChange)`.

Forms integration

  • sv-color-picker — ControlValueAccessor.[formControl], formControlName, [(ngModel)] and Signal Forms [formField] all work.

Best practices

  • Do: Provide brand `swatches` so users land on on-brand colors quickly.
  • Do: Expose the hex input for precise, copy-pasteable values.
  • Tip: Only enable `showAlpha` when transparency is actually meaningful for the value.

Accessibility

  • The gradient, hue and opacity controls are `role="slider"` and fully keyboard-operable: Arrow keys adjust (Shift for larger steps), Home/End jump to the ends.
  • Opening moves focus into the panel; Escape closes and returns focus to the trigger. Swatches expose `aria-label` + `aria-pressed`, and the hex input and sliders are labelled.
  • Implements ControlValueAccessor — works with `[(ngModel)]`, `[formControl]` and `formControlName`; `formControl.disable()` disables the trigger.

Feedback on Color Picker

Spotted a gap in this page, or something that didn't work as described? Comments are GitHub Discussions in the public styloviz/community repo, so posting needs a GitHub account.

Loads giscus.app and GitHub — nothing is fetched until you click.