Color Picker Panel 颜色选择器面板
用于在面板中选择颜色,支持 Hue(色相)与可选 Alpha(透明度),并可通过输入框粘贴 #RGB/#RRGGBB 或 rgb()/rgba() 进行回写。
基础用法
html
<template>
<dk-color-picker-panel v-model="value" />
</template>
<script setup>
import { ref } from 'vue'
const value = ref('#409EFF')
</script>展开
透明度(show-alpha)
html
<template>
<dk-color-picker-panel v-model="value" show-alpha format="rgb" />
</template>展开
禁用
html
<template>
<dk-color-picker-panel v-model="value" disabled />
</template>展开
属性
| 属性名 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| model-value / v-model | 绑定值 | string | '' |
| disabled | 是否禁用 | boolean | false |
| show-alpha | 是否显示透明度条 | boolean | false |
| format | 输出格式 | 'hex' | 'rgb' | 'hsl' | 'hex' |
| width | 面板宽度 | string | '280px' |
事件
| 事件名 | 说明 | 回调参数 |
|---|---|---|
| update:modelValue | v-model 更新 | (value: string) |
| active-change | 拖动过程中实时回调 | (value: string) |
| change | 结束拖动/输入框回写后的变更 | (value: string) |
| update:rgba | RGBA 更新 | (rgba: { r: number; g: number; b: number; a: number }) |