Skip to content

useEyeDropper

Category
Export Size
283 B
Last Changed
3 weeks ago

Reactive EyeDropper API

Demo

isSupported: true
sRGBHex:

Usage

ts
import { 
useEyeDropper
} from '@vueuse/core'
const {
isSupported
,
open
,
sRGBHex
} =
useEyeDropper
()

Component Usage

This function also provides a renderless component version via the @vueuse/components package. Learn more about the usage.

vue
<template>
  <UseEyeDropper v-slot="{ 
isSupported
,
sRGBHex
,
open
}">
<
button
:disabled
="!
isSupported
" @
click
="
open
">
sRGBHex: {{
sRGBHex
}}
</
button
>
</UseEyeDropper> </template>

Type Declarations

ts
export interface EyeDropperOpenOptions {
  /**
   * @see https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal
   */
  
signal
?: AbortSignal
} export interface EyeDropper { new (): EyeDropper
open
: (
options
?: EyeDropperOpenOptions) =>
Promise
<{
sRGBHex
: string
}> [
Symbol
.
toStringTag
]: "EyeDropper"
} export interface UseEyeDropperOptions { /** * Initial sRGBHex. * * @default '' */
initialValue
?: string
} /** * Reactive [EyeDropper API](https://developer.mozilla.org/en-US/docs/Web/API/EyeDropper_API) * * @see https://vueuse.org/useEyeDropper * * @__NO_SIDE_EFFECTS__ */ export declare function
useEyeDropper
(
options
?: UseEyeDropperOptions): {
isSupported
:
ComputedRef
<boolean>
sRGBHex
:
ShallowRef
<string, string>
open
: (
openOptions
?: EyeDropperOpenOptions) =>
Promise
<
| {
sRGBHex
: string
} | undefined > } export type
UseEyeDropperReturn
=
ReturnType
<typeof
useEyeDropper
>

Source

SourceDemoDocs

Contributors

Anthony Fu
Jelf
Anthony Fu
SerKo
vaakian X
wheat

Changelog

v13.6.0 on
d32f8 - refactor: add @__NO_SIDE_EFFECTS__ annotations to all pure functions (#4907)
v12.0.0-beta.1 on
0a9ed - feat!: drop Vue 2 support, optimize bundles and clean up (#4349)

Released under the MIT License.

FREE WEEKEND
48 Hours of Unlimited Official Vue.js Certification Training
Reserve Your Spot
23-24 August