Skip to content
🌏 Translated with the assistance of DeepSeek and ChatGPT

ColorPicker

Pick a color you like.

Considering the poor matching effect with the selected color, ColorPicker does not have focus and hover border effects.

Basic Usage

modelValue is a color string value, and color is a color object value. Passing at least one of these two values enters controlled mode. If neither is passed or both are undefined, it becomes uncontrolled mode. In this case, you can pass the defaultValue and defaultColor props as default values.

rgb(151, 0, 255, 0.75)
rgb(151, 0, 255, 0.75)
rgb(151, 0, 255, 0.75)
{ "format": "rgb", "color": { "r": 151, "g": 0, "b": 255, "a": 191 } }
Hide source code

Color Formats

The component currently supports RGB, HEX, HSV, HSL, and HWB color formats.

RGB
rgb(0, 255, 68, 0.75)
hsl(136, 100%, 50%, 0.75)
Hide source code

Show Opacity

The component supports setting whether the color includes opacity via includeAlpha.

rgb(61, 190, 255)
hwb(200, 23.92%, 0%, 0.75)
Hide source code

Preset Colors

The preset prop provides preset color options.

rgb(255, 163, 0, 1)
Hide source code

Size and Shape

rgb(153, 31, 80, 1)
rgb(191, 38, 99, 1)
rgb(230, 46, 119, 1)
Hide source code

Icon Display

Hide source code

More Configurations

ColorPicker also has some features of the Input component.

Disabled, Readonly

rgb(255, 255, 255, 1)
rgb(255, 255, 255, 1)

Composite

Color:
rgb(255, 255, 255, 1)
Label:

Status

rgb(255, 255, 255, 1)
rgb(255, 255, 255, 1)
rgb(255, 255, 255, 1)
rgb(255, 255, 255, 1)

Expose

rgb(255, 255, 255, 1)
Hide source code

API

ColorPickerProps

AttributeTypeOptionalDefaultDescriptionVersion
modelValuestring | nullTrueThe string value of the color picker (controlled mode), supports v-model.0.2.0
defaultValuestring | nullTrueThe default string value of the color picker (uncontrolled mode).0.2.0
colorColorValue | nullTrueThe object value of the color picker (controlled mode), supports v-model.0.2.0
defaultColorColorValue | nullTrueThe default object value of the color picker (uncontrolled mode).0.2.0
mode'hex' | 'rgb' | 'hsv' | 'hsl' | 'hwb'True'rgb'The color format of the color picker.0.2.0
includeAlphabooleanTruetrueWhether to include alpha transparency.0.2.0
presetstring[]TruePreset colors.0.2.0
disabledbooleanTruefalseWhether it is disabled.0.2.0
readonlybooleanTruefalseWhether it is read-only.0.2.0
size'medium' | 'large' | 'small'True'medium'Auto-fill input size.0.2.0
shape'medium' | 'large' | 'small'True'rect'Auto-fill input shape.0.2.0
showIconbooleanTruetrueWhether to display the icon.0.2.0
borderRadiusNumberOrPercentage | NumberOrPercentage[]TrueBorder radius, higher priority than shape, consistent with CSS border-radius behavior; single value or array of length 1 → all four corners take effect simultaneously; array of length 2 → [top-left & bottom-right, top-right & bottom-left]; array of length 3 → [top-left, top-right & bottom-left, bottom-right]; array of length 4 → applied clockwise to each corner.0.2.0
status'success' | 'warning' | 'error' | 'normal'True'normal'Form validation status.0.2.0
autofocusbooleanTruefalseNative <input> autofocus attribute.0.2.0
dropdownDestroyOnHidebooleanTruefalseWhether the dropdown panel is destroyed when hidden.0.2.0
pollSizeChangebooleanTruefalseEnable polling for component size changes, may affect performance.0.2.0
dropdownPropsOmit<PopoverProps, 'visible' | 'content'> & EmitEvent<PopoverEvents>TrueProperties of the dropdown selection panel.0.2.0

ColorPickerEvents

EventParameterDescriptionVersion
update:modelValuevalue: stringCallback for updating modelValue.0.2.0
update:colorvalue: ColorValueCallback for updating color.0.2.0
changecolorString: string, colorWithModel: ColorWithModel, event?: EventCallback when the color changes.0.2.0
blurevent: FocusEventCallback when the auto-fill input loses focus.0.2.0
focusevent: FocusEventCallback when the auto-fill input gains focus.0.2.0
dropdownOpenCallback when the dropdown panel is shown.0.2.0
dropdownCloseCallback when the dropdown panel is closed.0.2.0

ColorPickerExpose

AttributeTypeOptionalDefaultDescriptionVersion
focus() => voidFalseFocus the current control.0.2.0
blur() => voidFalseBlur the current control.0.2.0

ColorValue, ColorWithModel

ts
export type ColorValue = {
	format: 'rgb' | 'hsv' | 'hsl' | 'hwb'
	color: RgbaColor | HslaColor | HsvaColor | HwbaColor
}

export type ColorWithModel = {
	rgb: RgbaColor
	hsl: HslaColor
	hwb: HwbaColor
	hsv: HsvaColor
}

export type RgbaColor = { r: number; g: number; b: number; a: number }
export type HsvaColor = { h: number; s: number; v: number; a: number }
export type HslaColor = { h: number; s: number; l: number; a: number }
export type HwbaColor = { h: number; w: number; b: number; a: number }

EmitEvent

ts
export type EmitEvent<T extends Record<string, any>> = {
	[K in keyof T as `on${Capitalize<K & string>}`]?: (...args: T[K]) => void
}

NumberOrPercentage

ts
export type NumberOrPercentage = number | `${number}%`