mirror of https://github.com/ElemeFE/element
1.7 KiB
1.7 KiB
ColorPicker
ColorPicker is a color selector supporting multiple color formats.
Basic usage
:::demo ColorPicker requires a string typed variable to be bound to v-model.
<div class="block">
<span class="demonstration">With default value</span>
<el-color-picker v-model="color1"></el-color-picker>
</div>
<div class="block">
<span class="demonstration">With no default value</span>
<el-color-picker v-model="color2"></el-color-picker>
</div>
<script>
export default {
data() {
return {
color1: '#20a0ff',
color2: null
}
}
};
</script>
:::
Alpha
:::demo ColorPicker supports alpha channel selecting. To activate alpha selecting, just add the show-alpha
attribute.
<el-color-picker v-model="color3" show-alpha></el-color-picker>
<script>
export default {
data() {
return {
color3: 'rgba(19, 206, 102, 0.8)'
}
}
};
</script>
:::
Attributes
Attribute | Description | Type | Accepted Values | Default |
---|---|---|---|---|
show-alpha | whether to display the alpha slider | boolean | — | false |
color-format | color format of v-model | string | hsl / hsv / hex / rgb | hex (when show-alpha is false)/ rgb (when show-alpha is true) |
Events
Event Name | Description | Parameters |
---|---|---|
change | triggers when input value changes | color value |