Preview Updated 2026-05-10

ColorPicker

HSV palette + hue slider + alpha slider + multi-format input — opens in a popover from a trigger or expands inline via panelOnly.

Basic usage

v-model binds a color string. Once open, you can drag on the HSV palette, adjust hue, switch between HEX / RGB / HSL formats, and edit the value as text. Preset swatches let you pick a color in one click.

#3b82f6
<script setup lang="ts">
import { ref } from 'vue';
import { CfColorPicker } from '@chufix-design/vue';

const value = ref('#3b82f6');
</script>

<template>
<CfColorPicker v-model="value" />
</template>
import { useState } from 'react';
import { CfColorPicker } from '@chufix-design/react';

export default function Demo() {
const [value, setValue] = useState('#3b82f6');
return <CfColorPicker value={value} onChange={setValue} />;
}

Alpha

Enabling showAlpha adds an alpha slider; the output automatically switches to rgba() / hsla() / 8-digit HEX.

<CfColorPicker v-model="value" show-alpha default-format="rgb" />
<CfColorPicker value={value} showAlpha defaultFormat="rgb" onChange={setValue} />

Inline panel

panelOnly keeps the panel always expanded inline — common for settings sidebars or theme editors.

<CfColorPicker v-model="value" panel-only show-alpha />
<CfColorPicker value={value} panelOnly showAlpha onChange={setValue} />

API

PropTypeDefaultDescription
modelValue (Vue) / value (React)string'#3b82f6'Color string; accepts hex / rgb / rgba / hsl / hsla
defaultFormat'hex' | 'rgb' | 'hsl''hex'Output format (auto switches to -a suffix or 8-digit HEX when alpha is on)
showAlphabooleanfalseWhether to show the alpha slider
presetsstring[]12-color default paletteCustom preset swatches
panelOnlybooleanfalseSkip the trigger and render the panel directly
disabledbooleanfalseDisabled
size'sm' | 'md' | 'lg''md'Size (trigger only)

Events: update:modelValue / change (React: onChange).

Color parsing accepts #rgb #rgba #rrggbb #rrggbbaa rgb() rgba() hsl() hsla(). The input field re-parses on blur and falls back to the last valid value if it can’t be parsed.

反馈与讨论

ColorPicker · Discussion

0
0 / 600
一键发送
正在加载评论...