ColorPickerPanel
Color picker panel without an input box
Useful when embedding a pure color-picking panel or custom popup content inside a form. It exposes the same props as ColorPicker and follows the same formatting and disabled-state logic, so controlled forms can get string values without extra adaptation.
Markup Schema Example
<script lang="ts" setup>
import { createForm } from '@silver-formily/core'
import { ColorPickerPanel, Form, FormItem, Submit } from '@silver-formily/element-plus'
import { createSchemaField } from '@silver-formily/vue'
const form = createForm()
const predefine = ['#409eff', '#67c23a', '#e6a23c', 'rgba(255, 69, 0, 0.68)']
const { SchemaField, SchemaStringField } = createSchemaField({
components: {
FormItem,
ColorPickerPanel,
},
})
async function onSubmit(value: any) {
console.log(value)
}
</script>
<template>
<Form :form="form" layout="vertical">
<SchemaField>
<SchemaStringField
name="primary"
title="Theme Color"
x-decorator="FormItem"
x-component="ColorPickerPanel"
:x-component-props="{
style: 'width: 320px',
predefine,
}"
/>
<SchemaStringField
name="alpha"
title="Transparent Theme Color"
x-decorator="FormItem"
x-component="ColorPickerPanel"
:x-component-props="{
showAlpha: true,
style: 'width: 320px',
}"
/>
</SchemaField>
<Submit style="margin-top: 12px" @submit="onSubmit">
Submit
</Submit>
</Form>
</template>查看源码
Template Example
<script lang="ts" setup>
import { createForm } from '@silver-formily/core'
import { ColorPickerPanel, Form, FormItem, Submit } from '@silver-formily/element-plus'
import { Field } from '@silver-formily/vue'
const form = createForm()
const predefine = ['#409eff', '#67c23a', '#e6a23c', 'rgba(255, 69, 0, 0.68)']
async function onSubmit(value: any) {
console.log(value)
}
</script>
<template>
<Form :form="form" layout="vertical">
<Field
name="primary"
title="Theme Color"
:decorator="[FormItem]"
:component="[
ColorPickerPanel,
{
style: 'width: 320px',
predefine,
},
]"
/>
<Field
name="alpha"
title="Transparent Theme Color"
:decorator="[FormItem]"
:component="[
ColorPickerPanel,
{
showAlpha: true,
style: 'width: 320px',
},
]"
/>
<Submit style="margin-top: 12px" @submit="onSubmit">
Submit
</Submit>
</Form>
</template>查看源码
API
See https://element-plus.org/en-US/component/color-picker.html