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
Show code Copy < nana-color-picker value = "#3b82f6" alpha ></ nana-color-picker >
The variant attribute switches the layout: spectrum (default), grid
(palette-first), or swatch (swatches only). Add notrigger to render inline
without the popover.
Show code Copy < nana-color-picker variant = "grid" value = "#cc0000" notrigger ></ nana-color-picker >
< nana-color-picker
variant = "swatch"
value = "#10b981"
swatches = "#ef4444,#f59e0b,#10b981,#3b82f6,#6366f1,#8b5cf6"
></ nana-color-picker >
Property Attribute Type Default Description alphaalphabooleanfalsecontrastAgainstcontrastAgainststring''disableddisabledbooleanfalseformatformatColorFormat'hex'notriggernotriggerbooleanfalseRender the picker inline without a trigger button / popover readOnlyreadOnlybooleanfalseshowEyedroppershowEyedropperbooleantrueshowRecentshowRecentbooleantrueswatchesswatchesstring'#0f1f1d,#ef4444,#f59e0b,#10b981,#3b82f6,#6366f1,#8b5cf6,#ec4899,#64748b,#ffffff'valuevaluestring'#3b82f6'variantvariantColorPickerVariant'spectrum'
Method Returns Description 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
Event Description nana-color-inputLive value while dragging a slider/canvas (throttled) nana-color-changeCommitted value (pointer release, Enter, swatch click) nana-color-openThe popover opened nana-color-closeThe popover closed nana-changeCommitted value, { value } (mirrors other form controls)
Key Context Action Arrow keys Canvas Nudge saturation/value by 1 (Shift: 10) Arrow keys Hue / alpha slider Nudge by 1 (Shift: 10); hue wraps at 0/360 Escape Popover Close and return focus to the trigger
Property Description --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
Part Description ::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