Skip to main content

Starwind UI v3.0 beta is now available! Read the migration guide

Color Picker

Brand color

Color Picker combines Starwind’s styled composition with the vendorable Color Picker Primitive and the portable createColorPicker Runtime controller. The default ColorPickerContent composition uses the composite Starwind Select format control, includes all four editing formats, and keeps form ownership on Color Picker.

Installation

Framework Availability

Astro Available React Available

Color Picker is available for Astro and React.

The 0.1.0 styled component installs its Popover, Select, and Native Select dependencies. To own the Primitive adapter source too, run starwind primitives add color-picker.

Usage

Native format control

ColorPickerInput uses the composite ColorPickerFormatSelect by default. Set formatControl="native" to render ColorPickerNativeFormatSelect for browser-native interaction and progressive enhancement. Both controls edit the same Color Picker format state and neither creates a second submitted form value.

Accent color

Four color formats

Color Picker supports hex, rgb, hsl, and hsb. The value input, selected format, area, channel controls, swatches, CSS thumb colors, and hidden form value stay synchronized after each accepted edit.

HEX
RGB
HSL
HSB

Forms and state

Put name, form, and required on ColorPicker or ColorPickerRoot, then render one ColorPickerHiddenInput. It is the sole submitted field. Native form reset restores the initial value and format; disabled prevents interaction and submission, while readOnly preserves the value without allowing edits. To offer the advanced Clear action, explicitly pair root allowEmpty with showClear on ColorPickerContent; showClear does not enable empty values by itself.

Required accent
Disabled
Read only
Not submitted

Anatomy

  • ColorPicker composes the floating Popover; use ColorPickerRoot for an inline editor.
  • ColorPickerLabel, ColorPickerControl, and ColorPickerTrigger form the closed control.
  • ColorPickerContent provides the canonical area, channel sliders, value input, format control, optional actions, separator, and consumer swatch slot.
  • ColorPickerValueInput is the standalone exact-value editor.
  • ColorPickerFormatSelect is the composite Select path; ColorPickerNativeFormatSelect is the native path.
  • ColorPickerSwatchGroup and ColorPickerSwatch provide preset choices.
  • ColorPickerHiddenInput owns native form submission, validity, form association, and reset.

Use the Primitive reference when you need custom anatomy or raw adapter parts. Use the Runtime reference for controller state, events, setters, and raw HTML initialization.

Accessibility

  • Give every picker a visible ColorPickerLabel or an equivalent accessible name.
  • Keep the generated range inputs available so area and channel editing remains keyboard operable.
  • The composite format control owns combobox/listbox semantics; the native option uses a labeled <select>. Do not render both choices for one user-facing format control.
  • Swatches are buttons with selected state, and the popup returns focus to its trigger on Escape.
  • Use required, disabled, and readOnly according to form intent, and do not communicate state through color alone.
  • Preserve visible focus styles and sufficient contrast around thumbs, swatches, and controls in custom themes.

API Reference

Styled Component API

These props are added or materially changed by the installed Astro styled component. Standard HTML attributes remain available through the inherited interfaces noted below. Follow the Primitive and Runtime links for lower-level behavior props.

Color Picker Root

Inherits div attributes. Omits `defaultValue`, `dir`, `onChange`, and `value`.

Contains the following additional props:

Prop Type Default Toggle details
defaultValue import("@starwind-ui/runtime/color-picker").ColorPickerValue "#000000"
Description
Sets the initial value when the component is uncontrolled.
Classification
Primitive override
Primitive prop
color-picker.Root.defaultValue
dir import("@starwind-ui/runtime/color-picker").ColorPickerDirection
Description
Sets the picker direction explicitly.
Classification
Primitive override
Primitive prop
color-picker.Root.dir
format import("@starwind-ui/runtime/color-picker").ColorPickerFormat "hex"
Description
Sets the editable color format.
Classification
Primitive override
Primitive prop
color-picker.Root.format
size "sm" | "md" | "lg" "md"
Description
Selects the component's visual size.
Classification
Styled variant

Color Picker

Inherits ColorPickerRoot props.

Contains the following additional props:

Prop Type Default Toggle details
closeDelay number 200
Description
Sets the delay in milliseconds before closing.
Classification
Wrapper prop
closeOnEscape boolean true
Description
Allows the surface to close when Escape is pressed.
Classification
Wrapper prop
closeOnOutsideInteract boolean true
Description
Allows the surface to close after an outside interaction.
Classification
Wrapper prop
defaultOpen boolean false
Description
Sets the initial open state when the component is uncontrolled.
Classification
Wrapper prop
modal boolean false
Description
Controls whether interaction outside the surface is blocked while open.
Classification
Wrapper prop
openOnHover boolean false
Description
Allows pointer hover to open the surface.
Classification
Wrapper prop

Color Picker Label

Inherits label attributes.

Contains the following additional props:

Prop Type Default Toggle details
size "sm" | "md" | "lg" "md"
Description
Selects the component's visual size.
Classification
Styled variant

Color Picker Control

Inherits div attributes.

Contains the following additional props:

Prop Type Default Toggle details
size "sm" | "md" | "lg" "md"
Description
Selects the component's visual size.
Classification
Styled variant

Color Picker Input

Inherits div attributes.

Contains the following additional props:

Prop Type Default Toggle details
formatControl "select" | "native" "select"
Description
Chooses the composite Select or progressively enhanced native format control.
Classification
Wrapper prop
size "sm" | "md" | "lg" "md"
Description
Selects the component's visual size.
Classification
Styled variant

Color Picker Trigger

Inherits PopoverTrigger props.

Contains the following additional props:

Prop Type Default Toggle details
showValueText boolean true
Description
Shows the formatted value beside the trigger swatch.
Classification
Wrapper prop
size "sm" | "md" | "lg" "md"
Description
Selects the component's visual size.
Classification
Styled variant

Color Picker Content

Inherits PopoverContent props.

Contains the following additional props:

Prop Type Default Toggle details
alpha boolean true
Description
Includes alpha controls in the picker content.
Classification
Wrapper prop
showClear boolean false
Description
Shows the generated clear-value control.
Classification
Wrapper prop
showEyeDropper boolean true
Description
Shows the EyeDropper trigger when supported.
Classification
Wrapper prop
size "sm" | "md" | "lg" "md"
Description
Selects the component's visual size.
Classification
Styled variant

Color Picker Area

Inherits div attributes.

Contains the following additional props:

Prop Type Default Toggle details
size "sm" | "md" | "lg" "md"
Description
Selects the component's visual size.
Classification
Styled variant

Color Picker Area Thumb

Inherits span attributes.

Contains the following additional props:

Prop Type Default Toggle details
size "sm" | "md" | "lg" "md"
Description
Selects the component's visual size.
Classification
Styled variant

Color Picker Sliders

Inherits div attributes.

Contains the following additional props:

Prop Type Default Toggle details
alpha boolean true
Description
Includes an alpha channel slider.
Classification
Wrapper prop
size "sm" | "md" | "lg" "md"
Description
Selects the component's visual size.
Classification
Styled variant

Color Picker Channel Slider

Inherits div attributes.

Contains the following additional props:

Prop Type Default Toggle details
channel Required import("@starwind-ui/runtime/color-picker").ColorPickerChannel
Description
Selects the channel rendered by this slider.
Classification
Primitive override
Primitive prop
color-picker.ChannelSlider.channel
size "sm" | "md" | "lg" "md"
Description
Selects the component's visual size.
Classification
Styled variant

Color Picker Channel Input

Inherits input attributes.

Contains the following additional props:

Prop Type Default Toggle details
channel Required import("@starwind-ui/runtime/color-picker").ColorPickerChannel
Description
Selects the channel edited by this input.
Classification
Primitive override
Primitive prop
color-picker.ChannelInput.channel
size "sm" | "md" | "lg" "md"
Description
Selects the component's visual size.
Classification
Styled variant

Color Picker Value Input

Inherits input attributes. Omits `size`.

Contains the following additional props:

Prop Type Default Toggle details
size "sm" | "md" | "lg" "md"
Description
Selects the component's visual size.
Classification
Styled variant

Color Picker Native Format Select

Inherits select attributes. Omits `size`.

Contains the following additional props:

Prop Type Default Toggle details
size "sm" | "md" | "lg" "md"
Description
Selects the component's visual size.
Classification
Styled variant

Color Picker Format Select

Inherits div attributes.

Contains the following additional props:

Prop Type Default Toggle details
size "sm" | "md" | "lg" "md"
Description
Selects the component's visual size.
Classification
Wrapper prop

Color Picker Value Swatch

Inherits span attributes.

Contains the following additional props:

Prop Type Default Toggle details
size "sm" | "md" | "lg" "md"
Description
Selects the component's visual size.
Classification
Styled variant

Color Picker Swatch Group

Inherits div attributes.

Contains the following additional props:

Prop Type Default Toggle details
size "sm" | "md" | "lg" "md"
Description
Selects the component's visual size.
Classification
Styled variant

Color Picker Swatch

Inherits button attributes.

Contains the following additional props:

Prop Type Default Toggle details
disabled boolean false
Description
Disables interaction with the component.
Classification
Wrapper prop
size "sm" | "md" | "lg" "md"
Description
Selects the component's visual size.
Classification
Styled variant
value Required import("@starwind-ui/runtime/color-picker").ColorPickerValue
Description
Controls or identifies the component value.
Classification
Wrapper prop

Color Picker Eye Dropper

Inherits button attributes.

Contains the following additional props:

Prop Type Default Toggle details
size "sm" | "md" | "lg" "md"
Description
Selects the component's visual size.
Classification
Styled variant

Color Picker Clear

Inherits button attributes.

Contains the following additional props:

Prop Type Default Toggle details
size "sm" | "md" | "lg" "md"
Description
Selects the component's visual size.
Classification
Styled variant

Color Picker Hidden Input

Inherits input attributes.

Contains the following additional props:

Prop Type Default Toggle details
size "sm" | "md" | "lg" "md"
Description
Selects the component's visual size.
Classification
Styled variant

Primitive And Runtime API

Use these references when you need the lower-level behavior APIs behind Color Picker.

Runtime API

Color Picker primitive
createColorPicker from @starwind-ui/runtime/color-picker

Changelog

v0.1.0

  • Added the Runtime-backed Astro and React Color Picker with composite and native format controls, all four color formats, alpha, swatches, nullable values, and native form participation.
  • Established the canonical styled composition with a no-Clear default; advanced Clear usage explicitly pairs root allowEmpty with content showClear.
  • See the Color Picker Primitive for the underlying unstyled anatomy and behavior API.