Skip to content

API in Capabilities

EyeDropper API

Published

Limited availabilityNot supported in Chrome (Android), Firefox (Desktop), Firefox (Android), Safari (macOS), Safari (iOS)WICG draft

The EyeDropper API lets users pick a colour anywhere on screen with the browser’s eyedropper tool. new EyeDropper().open() suppresses input to the page, lets the user pick one pixel anywhere on screen, including outside the browser window, and resolves with that pixel’s colour as a #rrggbb string. It exists so custom colour pickers do not have to screenshot the page to sample a colour.

Chrome 95 and Edge 95 ship it on desktop only; BCD records version_added: false for Chrome on Android and Android WebView. Firefox and Safari have no implementation (BCD api.EyeDropper). Chrome 96 moved the interface behind [SecureContext], so on http:// origins other than localhost window.EyeDropper is undefined.

const eyeDropper = new EyeDropper();
eyeDropper.open()
eyeDropper.open(options)

The constructor takes no arguments and does nothing visible. open() returns a Promise<ColorSelectionResult>; the result’s only member is sRGBHex, a DOMString holding a valid simple colour such as "#3366ff". While the promise is pending the page is in “eyedropper mode” and receives no UI events. open() must be called with transient user activation, so it belongs inside a click or keydown handler.

open() takes one optional options argument, a ColorSelectionOptions dictionary with a single member.

Member Type Required Description
signal AbortSignal No Aborting the signal exits eyedropper mode, dismisses the browser UI, and rejects the pending promise with the signal’s abort reason (an AbortError DOMException unless abort() was given another reason).

The resolved ColorSelectionResult dictionary has one member, sRGBHex, a six-digit #rrggbb string. The specification exposes no alpha channel, so a translucent pixel is reported as the colour composited on screen.

open() rejects its promise with one of the following. The first two are checked synchronously before any UI appears.

Exception Condition
NotAllowedError The window has no transient user activation.
InvalidStateError Another eyedropper is already open in this window, or the object is no longer associated with a window.
AbortError The user cancelled the selection (Escape in Chrome) before picking a pixel.
OperationError The browser could not present its UI or could not read screen content; Chrome also uses it when the feature is disabled by policy.
The signal’s abort reason options.signal was already aborted when open() was called, or was aborted while the promise was pending.

Test "EyeDropper" in window before showing a pick button and keep an <input type="color"> in the page as the path for Firefox, Safari, and every mobile browser.

Picking a colour with a native colour input as the fallback

Section titled “Picking a colour with a native colour input as the fallback”

When the constructor is missing, hide the pick button and leave the colour input visible; the input gives every browser a working colour picker, just not one that can sample pixels outside the page.

const pickButton = document.querySelector("#pick");
const colorInput = document.querySelector("#color");
if (!("EyeDropper" in window)) {
pickButton.hidden = true;
colorInput.hidden = false;
} else {
pickButton.addEventListener("click", async () => {
const eyeDropper = new EyeDropper();
try {
const { sRGBHex } = await eyeDropper.open();
colorInput.value = sRGBHex;
} catch (err) {
if (err.name !== "AbortError") console.error(`${err.name}: ${err.message}`);
}
});
}

AbortError is the normal outcome when the user presses Escape, so the handler ignores it and surfaces only the other names.

Cancelling a pick from a timeout or a second button

Section titled “Cancelling a pick from a timeout or a second button”

Pass an AbortSignal when a pick should not stay open indefinitely. AbortSignal.timeout() rejects with a TimeoutError reason, which the catch branch distinguishes from the user’s own cancel.

async function pickWithTimeout(ms) {
if (!("EyeDropper" in window)) return null;
const eyeDropper = new EyeDropper();
try {
const { sRGBHex } = await eyeDropper.open({ signal: AbortSignal.timeout(ms) });
return sRGBHex;
} catch (err) {
if (err.name === "TimeoutError") console.info("Eyedropper closed after timeout");
return null;
}
}
document.querySelector("#pick").addEventListener("click", async () => {
const hex = await pickWithTimeout(10_000);
if (hex) document.documentElement.style.setProperty("--accent", hex);
});

A null return covers unsupported browsers, timeouts, and user cancellation alike, so the caller can handle all three with one branch.

Specifications

SpecificationStatus
EyeDropper APIWICG draft
  • Legend
  • Yes
  • Partial
  • Flag
  • No
  • Unknown
Browser / PlatformSupportVersionsConfidenceSourceNotes
Chrome (Desktop)#Yes95highsource12
Chrome (Android)#No—highsource3
Edge (Desktop)#Yes95highsource456
Firefox (Desktop)#No—highsource7
Firefox (Android)#No—highsource89
Safari (macOS)#No—highsource10
Safari (iOS)#No—highsource1112
Samsung Internet#No—highsource1314
WebView (Android)#No—highsource15
  1. Before Chrome 120, the EyeDropper API is not available on ChromeOS. See bug 40720753 (https://crbug.com/40720753).
  2. Available on Linux X11, but not available on Linux Wayland. See bug 40720753 (https://crbug.com/40720753).
  3. No Chrome Android support is recorded in browser-compat-data.
  4. Before Chrome 120, the EyeDropper API is not available on ChromeOS. See bug 40720753 (https://crbug.com/40720753).
  5. Available on Linux X11, but not available on Linux Wayland. See bug 40720753 (https://crbug.com/40720753).
  6. Derived by browser-compat-data mirroring from Chrome.
  7. No Firefox support is recorded in browser-compat-data.
  8. No Firefox for Android support is recorded in browser-compat-data.
  9. Derived by browser-compat-data mirroring from Firefox.
  10. No Safari support is recorded in browser-compat-data.
  11. No Safari on iOS support is recorded in browser-compat-data.
  12. Derived by browser-compat-data mirroring from Safari.
  13. No Samsung Internet support is recorded in browser-compat-data.
  14. Derived by browser-compat-data mirroring from Chrome Android.
  15. Implementation tracking: https://crbug.com/40791573.

Source data: /compatibility/eyedropper.json · Global usage: 39 % (StatCounter 2026-09, CC BY-SA 4.0)

Source: spec · MDN · Last verified 2026-10-03 · Confidence: high (computed from sources)