Skip to content
Nana UI

Color Picker

View .md Download

A full-featured color selection component built on Lit. Combines a saturation/value canvas, hue and alpha sliders, multi-format text input, swatches, and an eyedropper into a single popover-driven control.

beta since v0.0.14

The variant attribute switches the layout: spectrum (default), grid (palette-first), or swatch (swatches only). Add notrigger to render inline without the popover.

PropertyAttributeTypeDefaultDescription
alphabooleanfalse
contrastAgainststring''
disabledbooleanfalse
formatColorFormat'hex'
notriggerbooleanfalseRender the picker inline without a trigger button / popover
readOnlybooleanfalse
showEyedropperbooleantrue
showRecentbooleantrue
swatchesstring'#0f1f1d,#ef4444,#f59e0b,#10b981,#3b82f6,#6366f1,#8b5cf6,#ec4899,#64748b,#ffffff'
valuestring'#3b82f6'
variantColorPickerVariant'spectrum'
MethodReturnsDescription
open() / close()voidOpen or close the popover
setValue(color)voidSet the value from any supported format
getHex()stringCurrent value as #rrggbb(aa)
getRGB(){r,g,b,a}Current value as RGB(A)
getHSL(){h,s,l,a}Current value as HSL(A)
getContrastRatio(against?)number | nullWCAG contrast ratio against a color
EventDescription
eventName
nana-changeCommitted value, `{ value }` (mirrors other form controls)
nana-color-openThe popover opened
nana-color-closeThe popover closed
nana-color-inputLive value while dragging a slider/canvas (throttled)
nana-color-changeCommitted value (pointer release, Enter, swatch click)
KeyContextAction
Arrow keysCanvasNudge saturation/value by 1 (Shift: 10)
Arrow keysHue / alpha sliderNudge by 1 (Shift: 10); hue wraps at 0/360
EscapePopoverClose and return focus to the trigger
PropertyDescription
--nana-color-picker-widthWidth of the spectrum picker (default 16rem)
--nana-color-picker-thumb-sizeDiameter of the canvas/slider thumbs
--nana-color-picker-swatch-sizeTrigger swatch dimensions
PartDescription
::part(base)The inline picker container
::part(trigger)The trigger button (popover mode)
::part(panel)The popover panel
::part(sv)The saturation/value canvas
::part(preview)The color preview swatch
import "@nana-tec/ui-components/color-picker";
Explore Color Picker interactively Every state, prop, and edge case — with live controls — in Storybook.
View in Storybook