Pick a color: an inline picker (saturation area, hue, opacity, swatches) and a text field with the picker in a dropdown and an eyedropper. Pointer and keyboard; form-associated; hex, rgb or hsl, with or without alpha.
Keyboard: arrows move the area's thumb (saturation, brightness) or a slider's; Shift for 10× steps; Home/End on the sliders. The alpha slider shows when format has alpha.
Property
Attribute
Type
Default
Description
value
value
string
The color, written in format. Any color is accepted and rewritten in format. The value attribute is the initial value (restored on form reset).
format
formatreflects
string
hex
How value is written: hex, hexa, rgb, rgba, hsl or hsla. Formats ending in a show the opacity slider.
swatches
swatches
string
Preset colors below the picker: an array, or a comma-separated list in the attribute (commas inside rgb()/hsl() are kept).
swatchesPerRow
swatches-per-row
number
7
Swatches in each row.
swatchesOnly
swatches-onlyreflects
boolean
Only the swatches: no area nor sliders.
size
sizereflects
xs | sm | md | lg | xl
md
Width of the picker and size of its thumbs.
fullWidth
full-widthreflects
boolean
Takes the width of its container.
name
namereflects
string
Form field name.
disabled
disabledreflects
boolean
Not interactive.
label
label
string
Accessible name of the whole picker.
Event
Description
input
The color moved (every step of a drag).
change
The color settled: pointer released, a key pressed or a swatch chosen (read value).
Part
Description
saturation
The saturation/brightness area.
hue
The hue slider.
alpha
The opacity slider.
preview
The current color.
swatches
The swatches' grid.
<ray-color-input>
Type any CSS color (it becomes the value as soon as it is valid; invalid text goes back to the value on blur), or open the picker with a click or ArrowDown. The eyedropper shows only where the browser has the EyeDropper API.
Property
Attribute
Type
Default
Description
value
value
string
The color, written in format. The value attribute is the initial value (restored on form reset).
format
formatreflects
string
hex
How value is written: hex, hexa, rgb, rgba, hsl or hsla.
swatches
swatches
string
Preset colors in the dropdown (an array, or a comma-separated list).
swatchesPerRow
swatches-per-row
number
7
Swatches in each row.
placeholder
placeholder
string
Shown while empty.
hideEyedropper
hide-eyedropperreflects
boolean
Hides the eyedropper button.
open
openreflects
boolean
The dropdown is shown.
name
namereflects
string
Form field name.
label
label
string
Label above the field.
description
description
string
Help text.
error
error
string
Error message; marks the field invalid.
required
requiredreflects
boolean
Must have a color.
disabled
disabledreflects
boolean
Not interactive.
size
sizereflects
xs | sm | md | lg | xl
sm
Field height and font size.
radius
radiusreflects
string
Corner radius: xs…xl or a CSS length.
variant
variantreflects
default | filled | unstyled
default
Visual style of the field.
descriptionPosition
description-positionreflects
above | below
above
Where the description goes.
Event
Description
input
The color changed (typing a valid color, or moving the picker).
change
The color settled (picker released, a swatch, the eyedropper, or the field left with a new color).
ray-open
The dropdown opened.
ray-close
The dropdown closed.
Part
Description
input
The text field.
preview
The swatch of the current color.
eyedropper
The eyedropper button.
dropdown
The dropdown with the picker.
Texts
What it writes itself, in English; setStrings() translates them (Getting started: Languages).