Skip to content

Color Picker

Edit an exact color through native, text, channel, and spatial controls.

Usage

Native

Use the browser color input while keeping the same exact color value as the text controls.

Use the browser color input while keeping the same exact color value as the text controls.

HEX
#5b6df6

Alpha

Edit the alpha channel together with the visible color channels.

Edit the alpha channel together with the visible color channels.

HEX
#26c6a080

Controlled

Let the parent own the current value and apply accepted changes back to the component.

Let the parent own the current value and apply accepted changes back to the component.

HEX
#5b6df6

API

Vue package: @sectile/vue/color-picker

Components
  • ColorPickerRoot
  • ColorPickerLabel
  • ColorPickerControl
  • ColorPickerNativeInput
  • ColorPickerTextInput
  • ColorPickerChannelInput
  • ColorPickerCoordinateInput
  • ColorPickerCoordinateSlider
  • ColorPickerArea
  • ColorPickerAreaThumb
  • ColorPickerHueSlider
  • ColorPickerAlphaSlider
  • ColorPickerSwatch
  • ColorPickerValueText
  • ColorPickerFormatTrigger

Props

ColorPickerRootProps

allowAlpha

Whether the color value may include transparency.

alphaStep

Increment applied when the alpha channel changes.

as

Element or component rendered for this part.

asChild

Whether to merge this part into its single child instead of rendering a wrapper.

channelStep

Increment applied when a color channel changes.

defaultDraft

Editable draft used for uncontrolled initial state.

defaultFormat

Initial uncontrolled color format.

defaultValue

Initial value used when the component owns its state.

disabled

Whether interaction is unavailable.

draft

Controlled editable draft before commit.

form

ID of the native form associated with the control.

format

Controlled color format.

label

Accessible name announced for the control.

modelValue

Current value when state is controlled by the parent.

name

Name used for native form submission.

readonly

Whether the value can be inspected but not changed.

required

Whether the control must contain a valid value before submission.

ColorPickerPartProps

as

Element or component rendered for this part.

asChild

Whether to merge this part into its single child instead of rendering a wrapper.

ColorPickerChannelInputProps

as

Element or component rendered for this part.

asChild

Whether to merge this part into its single child instead of rendering a wrapper.

channel

Color channel edited by this input.

ColorPickerFormatTriggerProps

as

Element or component rendered for this part.

asChild

Whether to merge this part into its single child instead of rendering a wrapper.

format

Controlled color format.

ColorPickerCoordinateInputProps

as

Element or component rendered for this part.

asChild

Whether to merge this part into its single child instead of rendering a wrapper.

coordinate

Coordinate edited within the selected color model.

format

Controlled color format.

ColorPickerCoordinateSliderProps

as

Element or component rendered for this part.

asChild

Whether to merge this part into its single child instead of rendering a wrapper.

coordinate

Coordinate edited within the selected color model.

format

Controlled color format.

Slots

ColorPickerRootSlotProps

area

Current two-dimensional color area state.

channel

Current color channel.

coordinates

Current coordinates in the active color model.

cssColor

Current color serialized for CSS.

disabled

Whether interaction is unavailable.

draft

Current uncommitted input text.

format

Current color format.

readonly

Whether the value can be inspected but not changed.

text

Formatted text for the current value.

value

Current value exposed by this contract.

Events

ColorPickerRoot

update:draft

Emitted when the editable draft changes.

update:format

Emitted when the requested color format changes.

update:modelValue

Emitted when the component requests a new controlled value.

Other types

ColorPickerValueChangeHandler

ts
type ColorPickerValueChangeHandler = (value: string) => void

ColorPickerDraftChangeHandler

ts
type ColorPickerDraftChangeHandler = (value: string | null) => void

ColorPickerFormatChangeHandler

ts
type ColorPickerFormatChangeHandler = (value: ColorFormat) => void

ColorAreaValue

NameTypeRequired
xnumberYes
ynumberYes
huenumberYes
alphanumberYes

ColorChannel

ts
type ColorChannel = 'red' | 'green' | 'blue' | 'alpha'

ColorCoordinate

ts
type ColorCoordinate = ColorChannel | 'hue' | 'saturation' | 'lightness' | 'value' | 'cyan' | 'magenta' | 'yellow' | 'black' | 'chroma'

ColorCoordinateValue

NameTypeRequired
coordinateColorCoordinateYes
labelstringYes
valuenumberYes
minnumberYes
maxnumberYes
stepnumberYes
unit'' | '%' | '°'Yes

ColorFormat

ts
type ColorFormat = 'hex' | 'rgb' | 'hsl' | 'hsv' | 'cmyk' | 'oklch'

ColorModel

ts
type ColorModel = Exclude<ColorFormat, 'hex'>

ColorPickerPolicies

NameTypeRequired
allowAlphaboolean
channelStepnumber
alphaStepnumber

ColorValue

ts
type ColorValue = Rgba8

Parts

Shared scope: [data-scope="color-picker"]. Combine it with a part selector to keep styles local to this component.

PartSelectorRoleExtra attributes
root[data-part="root"]Defines the component boundary and owns its composed parts.
label[data-part="label"]Labels the component control.
control[data-part="control"]Groups the primary interactive controls.
native-input[data-part="native-input"]Keeps the native form control available for submission and platform behavior.
text-input[data-part="text-input"]Accepts a formatted text representation of the value.
channel-input[data-part="channel-input"]Edits one color channel numerically.
coordinate-input[data-part="coordinate-input"]Edits one coordinate of the current value.
coordinate-slider[data-part="coordinate-slider"]Adjusts one coordinate over a bounded range.
area[data-part="area"]Provides the two-dimensional interaction surface.
area-thumb[data-part="area-thumb"]Marks and controls the selected point in the area.
hue-slider[data-part="hue-slider"]Adjusts the color hue.
alpha-slider[data-part="alpha-slider"]Adjusts color opacity.
swatch[data-part="swatch"]Previews the selected color.
value-text[data-part="value-text"]Displays the formatted value as text.
format-trigger[data-part="format-trigger"]Changes the active value format.

Keyboard interaction

KeyBehavior
Arrow keysAdjust the active color coordinate or slider.
EnterCommit a typed color value.
EscapeCancel the typed draft and restore the accepted color.

Accessibility

Text inputs and sliders expose labels, ranges, current values, and channel purpose without relying on color alone.

Released under the MIT License.