Files
heroui-vue/apps/docs/demos/color-swatch-picker-controlled.vue
T

38 lines
900 B
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
import { shallowRef } from "vue";
import type { Color } from "@heroui-vue/components";
import {
ColorSwatchPicker,
ColorSwatchPickerIndicator,
ColorSwatchPickerItem,
ColorSwatchPickerSwatch,
parseColor,
} from "@heroui-vue/components";
const colors = [
"#F43F5E",
"#D946EF",
"#8B5CF6",
"#3B82F6",
"#06B6D4",
"#10B981",
"#84CC16",
];
const value = shallowRef<Color | null>(parseColor("#F43F5E"));
</script>
<template>
<div class="flex flex-col gap-4">
<ColorSwatchPicker v-model="value">
<ColorSwatchPickerItem v-for="color in colors" :key="color" :color="color">
<ColorSwatchPickerSwatch />
<ColorSwatchPickerIndicator />
</ColorSwatchPickerItem>
</ColorSwatchPicker>
<p class="text-sm text-muted">
已选:<span class="font-medium">{{ value?.toString("hex") }}</span>
</p>
</div>
</template>