feat: publish ColorField and shared color input parts

This commit is contained in:
maoyingjie
2026-10-27 11:53:02 +08:00
parent 108a120c81
commit 6a7a89be6b
34 changed files with 1511 additions and 39 deletions
@@ -0,0 +1,41 @@
<script setup lang="ts">
import { shallowRef } from "vue";
import type { Color } from "@heroui-vue/components";
import {
Button,
ColorField,
ColorFieldGroup,
ColorFieldInput,
ColorFieldPrefix,
ColorSwatch,
Description,
Label,
parseColor,
} from "@heroui-vue/components";
const value = shallowRef<Color | null>(parseColor("#0485F7"));
</script>
<template>
<div class="flex flex-col gap-4">
<ColorField class="w-[280px]" name="color" v-model="value">
<Label>颜色</Label>
<ColorFieldGroup>
<ColorFieldPrefix>
<ColorSwatch :color="value ?? undefined" size="xs" />
</ColorFieldPrefix>
<ColorFieldInput />
</ColorFieldGroup>
<Description>
当前值:{{ value ? value.toString("hex") : "(空)" }}
</Description>
</ColorField>
<div class="flex gap-2">
<Button variant="tertiary" @click="value = parseColor('#EF4444')">
设为红色
</Button>
<Button variant="tertiary" @click="value = parseColor('#10B981')">
设为绿色
</Button>
<Button variant="tertiary" @click="value = null">清空</Button>
</div>
</div>
</template>