ColorPickerRoot
ColorPickerRoot verbindet eine Schaltfläche mit Farbmuster mit einem Popover und überlässt die eigentliche Editoroberfläche den Slots. Der Slot trigger erhält den aktuellen Stil des Farbmusters, der Standard-Slot die aktuelle Farbe aus dem Szenengraphen.
openChange meldet die gesamte Dauer einer Interaktion mit der Farbauswahl. cancel wird vor dem Schließen per Escape ausgegeben, sodass Nutzer von BindableValue das Lösen einer Variablenbindung und die Änderung der Füllung gemeinsam zurücknehmen können. Das Öffnen oder Fokussieren der Farbauswahl gibt keine Farbaktualisierung aus.
vue
<script setup lang="ts">
import { ref } from 'vue'
import type { Color } from '@pairdraw/scene-graph/primitives'
import { ColorPickerRoot } from '@pairdraw/vue/primitives/ColorPicker'
const color = ref<Color>({ r: 0.2, g: 0.5, b: 0.9, a: 1 })
</script>
<template>
<ColorPickerRoot
:color="color"
@update="color = $event"
@open-change="open => console.log(open)"
@cancel="console.log('cancel')"
>
<template #trigger="{ style }">
<button :style="style" aria-label="Edit color" />
</template>
<template #default="{ color: currentColor }">
<output>{{ currentColor.r }}, {{ currentColor.g }}, {{ currentColor.b }}</output>
</template>
</ColorPickerRoot>
</template>Generierte API-Referenz
ColorPickerRoot
Generated from packages/vue/src/primitives/ColorPicker/ColorPickerRoot.vue
Props
| Prop | Default | Type |
|---|---|---|
color* | — | Color |
label | "Edit color" | string | undefined |
ui | — | ColorPickerUI | undefined |
colorProfileThe profile the color is stored in; the trigger's swatch then draws the color the canvas draws.
Defaults to sRGB. | "srgb" | ColorProfile | undefined |
escapeRevertsFor a colour with no undo history, such as a preference: Escape closing the picker puts back
the colour it opened with. Otherwise Escape keeps the edit, as Figma's picker does. | false | boolean | undefined |
keepOpenWhether a press outside the picker should leave it open, such as one that samples the canvas. | — | PickerKeepOpen | undefined |
Events
| Event | Payload | Description |
|---|---|---|
cancel | [cause: PickerCancelCause] | |
commit | [] | |
update | [color: Color] | |
openChange | [open: boolean] |
Slots
| Slot | Props | Description |
|---|---|---|
trigger | { style: { background: string; }; } | |
default | { color: Color; update: (next: Color) => void; } |