We use cookies to ensure you get the best experience on our website. Read our privacy policy

Skip to main content

Directory

Color Picker Component

The Color Picker component provides an intuitive interface for color selection with support for multiple color formats, eyedropper functionality, and color history. Built with accessibility and user experience in mind, it offers rich functionality including format switching, opacity control, and keyboard navigation.

  • Check Circle

    Multiple Color Formats: Support for HEX, RGB, RGBA, HSL, and HSLA

  • Check Circle

    Eyedropper Tool: Pick colors from anywhere on screen

  • Check Circle

    Color History: Track and reuse recently selected colors

  • Check Circle

    Keyboard Navigation: Full keyboard support with intuitive controls

  • Check Circle

    Accessibility: ARIA compliance and screen reader support

Choose a color
<ColorPicker label="Choose a color" />

The color picker supports different size variants through the size prop.

<ColorPicker size="sm" />
<ColorPicker size="default" />
<ColorPicker size="lg" />
<ColorPickerPanel isModal={false} />

Add the required prop to mark the color picker as a required field.

Required Color *
<ColorPicker required label="Required Color" />

Set an initial color using the value prop.

<ColorPicker value="#ff00FF1e" />

You can listen to the change custom event emitted by the color picker component:

Waiting for events to be emitted… (Click on the color picker to see the events)
Color Change Event
CustomEvent<{
id?: string; // id of the color picker
name?: string; // name of the hidden input
color: string; // selected color in current format
format: 'hex' | 'rgb' | 'rgba' | 'hsl' | 'hsla'; // current color format
}>;
Color Picker Component Extends <div> HTMLElement
Prop Type Default Description
id string Unique identifier for the color picker
label string Label text for the color picker
required boolean false Mark field as required
size sm | default | lg default Size variant of the color picker
value string #ffffff Initial color value
variant default default Visual style variant

The color picker component supports an error state. Set the data-state attribute to error to indicate validation errors.

<ColorPicker data-state="error" />
Key Action
Space/Enter Open/close color picker + select color
Tab Navigate through controls
Arrow Keys Adjust color values
Escape Close color picker

Limited Time Launch Sale

Add professional color selection to your web applications with our Color Picker component. Get our AstroJS starter template now!

GET 60% OFF!
North Star Themes Logo

Subscribe to our newsletter

Get the latest AstroJS tips and tricks right to your inbox

Email: [email protected]

© 2025 North Star Themes

Web Kit Provided By North Star Themes