Skip to content

ColorPickerRoot ​

ColorPickerRoot compone un disparador con muestra de color y una superficie de popover, y deja la interfaz del editor a sus ranuras. La ranura del disparador recibe el estilo actual de la muestra; la ranura predeterminada recibe el color actual del grafo de escena.

openChange informa del límite completo de la interacción con el selector. cancel se emite antes de un cierre con Escape, lo que permite a los consumidores de BindableValue revertir juntas la desvinculación de una variable y la actualización de la pintura. Abrir el selector o darle el foco no emite ninguna actualización de color.

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>

Referencia de API generada ​

ColorPickerRoot

Generated from packages/vue/src/primitives/ColorPicker/ColorPickerRoot.vue

Props

PropDefaultType
color*—Color
label"Edit color"string | undefined
ui—ColorPickerUI | undefined
colorProfile
The profile the color is stored in; the trigger's swatch then draws the color the canvas draws. Defaults to sRGB.
"srgb"ColorProfile | undefined
escapeReverts
For 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.
falseboolean | undefined
keepOpen
Whether a press outside the picker should leave it open, such as one that samples the canvas.
—PickerKeepOpen | undefined

Events

EventPayloadDescription
cancel[cause: PickerCancelCause]
commit[]
update[color: Color]
openChange[open: boolean]

Slots

SlotPropsDescription
trigger{ style: { background: string; }; }
default{ color: Color; update: (next: Color) => void; }

Véase también ​

Released under the MIT License.