Skip to content

ColorPicker

Used for selecting and setting colors. Supports multiple color modes (HEX, RGB, HSL), with alpha transparency control and predefined colors.

Showcase

ColorPicker provides a full-featured interactive demo. You can toggle alpha support and switch between sizes in real time.

Alpha:
Size:
Current value:#6366f1
Full Showcase

Basic Usage

Basic color picker functionality with HEX format two-way binding.

Basic Usage

Alpha Transparency

Enable show-alpha to support alpha channel adjustment, automatically switching to RGBA format.

Alpha Support

Predefined Colors

Display a set of preset quick-select colors at the bottom of the panel.

Predefined Colors

Disabled

The color picker becomes non-interactive when the disabled prop is set.

Disabled

Advanced Features

1. Intelligent Contrast Preview

The panel automatically calculates relative luminance between the selected color and background according to WCAG standards, providing real-time accessibility suggestions in the top-right corner to ensure designs meet visual accessibility requirements.

2. Cross-Platform EyeDropper

Based on the modern browser native EyeDropper API, it supports picking colors from anywhere on the screen (not limited to within the browser window), providing production-level support for professional design scenarios.

3. Bidirectional Input Field

The value display area at the bottom has been upgraded to a responsive input field. You can directly paste HEX or RGB codes from designers, and the component will instantly parse and locate the color.

Use in Nuxt

YhColorPicker is perfectly adapted for Nuxt 3/4. Under the Nuxt architecture, all related APIs (including EyeDropper detection) have been optimized for Client-Only environments, ensuring zero SSR warnings.

Use in Nuxt

API

Props

PropDescriptionTypeDefault
v-modelBinding valuestring
show-alphaWhether to support alphabooleanfalse
predefinePredefined color liststring[][]
sizeSize'large' | 'default' | 'small''default'
disabledWhether disabledbooleanfalse
popper-classPanel custom classstring
theme-overridesComponent-level theme overridesComponentThemeVarsundefined

Events

Event NameDescriptionParameters
changeTriggered when a color is confirmed(val: string)
active-changeTriggered when color changes in real-time within the panel(val: string)

Slots

This component does not expose component slots.

Expose

NameDescriptionType
visibleCurrent panel visibility state.Ref<boolean>
togglePopperToggle the panel open state.() => void
handleClearClear the current color value.() => void
handleConfirmConfirm the current color value.() => void

Theme Variables

VariableDescriptionDefault
--yh-color-picker-widthComponent base width60px
--yh-color-picker-panel-widthExpanded panel width280px
--yh-color-picker-border-radiusBorder radius12px

Type Exports

NameDescription
YhColorPickerPropsProps type for YhColorPicker
YhColorPickerEmitsEmits type for YhColorPicker
YhColorPickerSlotsSlots type for YhColorPicker
YhColorPickerExposeExpose type for YhColorPicker
YhColorPickerInstancePublic instance type for YhColorPicker

Released under the MIT License.