fn
useEyeDropper
v0.0.14testeddemoReactive 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
| Parameter | Type | Description |
|---|---|---|
options? | UseEyeDropperOptions | Options |
Returns
UseEyeDropperReturnisSupported, sRGBHex, and open()| Property | Type | Description |
|---|---|---|
isSupported | ComputedRef<boolean> | Whether the EyeDropper API is supported |
sRGBHex | ShallowRef<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. |