fn

useEyeDropper

v0.0.14testeddemo

Reactive wrapper around the EyeDropper API for picking colors from the screen.

Example

ts
const { isSupported, sRGBHex, open } = useEyeDropper();
if (isSupported.value)
  await open();

Demo

Loading demo…

Signature

ts
export function useEyeDropper(options: UseEyeDropperOptions ={ ... }

Parameters

ParameterTypeDescription
options?UseEyeDropperOptionsOptions

Returns

UseEyeDropperReturnisSupported, sRGBHex, and open()
PropertyTypeDescription
isSupportedComputedRef<boolean>Whether the EyeDropper API is supported
sRGBHexShallowRef<string>The most recently picked color, in sRGB hexadecimal format
open(openOptions?: EyeDropperOpenOptions) => Promise<EyeDropperResult | undefined>Open the eyedropper and let the user pick a color. Resolves with the result, or undefined when the API is unsupported.