37 lines
820 B
Vue
37 lines
820 B
Vue
<script setup lang="ts">
|
|
import { shallowRef } from "vue";
|
|
import type { Color } from "@heroui-vue/components";
|
|
import {
|
|
ColorField,
|
|
ColorFieldGroup,
|
|
ColorFieldInput,
|
|
ColorFieldPrefix,
|
|
ColorSwatch,
|
|
Label,
|
|
parseColor,
|
|
} from "@heroui-vue/components";
|
|
const color = shallowRef<Color | null>(parseColor("#0485F7"));
|
|
</script>
|
|
<template>
|
|
<ColorField
|
|
class="w-[280px]"
|
|
name="color"
|
|
as="div"
|
|
data-custom="foo"
|
|
v-slot="{ isFocused }"
|
|
v-model="color"
|
|
>
|
|
<Label>颜色</Label>
|
|
<ColorFieldGroup
|
|
as="div"
|
|
data-custom="foo"
|
|
:data-field-focused="isFocused || undefined"
|
|
>
|
|
<ColorFieldPrefix>
|
|
<ColorSwatch :color="color ?? undefined" size="xs" />
|
|
</ColorFieldPrefix>
|
|
<ColorFieldInput />
|
|
</ColorFieldGroup>
|
|
</ColorField>
|
|
</template>
|