HTMLInputElement: showPicker() method

Baseline Widely available *

This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2022.

* Some parts of this feature may have varying levels of support.

The HTMLInputElement.showPicker() method displays the browser picker for an input element.

This is the same picker that would normally be displayed when the element is selected, but can be triggered from a button press or other user interaction.

Commonly browsers implement it for inputs of these types: "date", "month", "week", "time", "datetime-local", "color", or "file". It can also be prepopulated with items from a <datalist> element or autocomplete attribute.

More generally, this method should ideally display the picker for any input element on the platform that has a picker.

Syntax

js
showPicker()

Parameters

None.

Return value

None (undefined).

Exceptions

InvalidStateError DOMException

Thrown if the element is not mutable, meaning that the user cannot modify it and/or that it cannot be automatically prefilled.

NotAllowedError DOMException

Thrown if not explicitly triggered by a user action such as a touch gesture or mouse click (the picker requires Transient activation).

SecurityError DOMException

Thrown if called in a cross-origin iframe, except for file and color pickers (exempt for historical reasons).

Security

Transient user activation is required. The user has to interact with the page or a UI element in order for this feature to work.

Examples

Feature Detection

The code below shows how to check if showPicker() is supported:

js
if ("showPicker" in HTMLInputElement.prototype) {
  // showPicker() is supported.
}

Normal input pickers

This example shows how this feature can be used for color and file input pickers.

Note: Pickers for date, datetime-local, month, time, week are launched in the same way. They cannot be shown here because live examples run in a cross-origin frame, and would cause a SecurityError

HTML

html
<p>
  <input type="color" />
  <button id="color">Show the color picker</button>
</p>

<p>
  <input type="file" />
  <button id="file">Show the file picker</button>
</p>

JavaScript

The code simply gets the previous element of the selected button and calls showPicker() on it.

js
document.querySelectorAll("button").forEach((button) => {
  button.addEventListener("click", (event) => {
    const input = event.srcElement.previousElementSibling;
    try {
      input.showPicker();
    } catch (error) {
      console.log(error);
    }
  });
});

Result

Click the button next to each input type to show its picker.

showPicker() for a datalist input

showPicker() can launch the picker for a list of options defined in a <datalist>.

First we define a <datalist> in HTML consisting of a number of internet browsers, an input of type text that uses it, and a button.

html
<datalist id="browsers">
  <option value="Chrome"></option>
  <option value="Firefox"></option>
  <option value="Opera"></option>
  <option value="Safari"></option>
  <option value="Microsoft Edge"></option>
</datalist>

<input type="text" list="browsers" />
<button>Select browser</button>

The code below adds an event listener that calls showPicker() when the button is clicked.

js
const button = document.querySelector("button");
const browserInput = document.querySelector("input");

button.addEventListener("click", () => {
  try {
    browserInput.showPicker();
  } catch (error) {
    // Fall back to another picker mechanism
  }
});

As for the other pickers, we can't show this code running as a live example because it runs in a cross-origin frame, and would cause a SecurityError.

showPicker() for autocomplete

showPicker() can launch a picker for an autocomplete input.

Here we define an input that takes an autocomplete option of "name".

html
<input autocomplete="name" /> <button>Show autocomplete options</button>

The code below shows the picker for the input when the button is clicked.

js
const button = document.querySelector("button");
const browserInput = document.querySelector("input");

button.addEventListener("click", () => {
  try {
    browserInput.showPicker();
  } catch (error) {
    // Fall back to another picker mechanism
  }
});

Specifications

Specification
HTML
# dom-input-showpicker

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
showPicker
Chrome – Full support
Chrome 99 (Release date: 2022-03-01)
footnote Full support
Edge – Full support
Edge 99 (Release date: 2022-03-03)
footnote Full support
Firefox – Full support
Firefox 101 (Release date: 2022-05-31)
footnote Full support
Opera – Full support
Opera 85 (Release date: 2022-03-23)
footnote Full support
Safari – Full support
Safari 16 (Release date: 2022-09-12)
footnote Full support
Chrome Android – Full support
Chrome Android 99 (Release date: 2022-03-01)
footnote Full support
Firefox for Android – Full support
Firefox for Android 101 (Release date: 2022-05-31)
footnote Full support
Opera Android – Full support
Opera Android 68 (Release date: 2022-03-30)
footnote Full support
Safari on iOS – Full support
Safari on iOS 16 (Release date: 2022-09-12)
footnote Full support
Samsung Internet – Full support
Samsung Internet 18 (Release date: 2022-08-08)
footnote Full support
WebView Android – Full support
WebView Android 99 (Release date: 2022-03-01)
footnote Full support
WebView on iOS – Full support
WebView on iOS 16 (Release date: 2022-09-12)
footnote Full support
autocomplete input
Chrome – Full support
Chrome 99 (Release date: 2022-03-01)
footnote Full support
Edge – Full support
Edge 99 (Release date: 2022-03-03)
footnote Full support
Firefox – No support
Firefox
footnote No support
Opera – Full support
Opera 85 (Release date: 2022-03-23)
footnote Full support
Safari – No support
Safari
footnote
footnote See bug 234009
Chrome Android – Full support
Chrome Android 99 (Release date: 2022-03-01)
footnote Full support
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – Full support
Opera Android 68 (Release date: 2022-03-30)
footnote Full support
Safari on iOS – No support
Safari on iOS
footnote
footnote See bug 234009
Samsung Internet – Full support
Samsung Internet 18 (Release date: 2022-08-08)
footnote Full support
WebView Android – Full support
WebView Android 99 (Release date: 2022-03-01)
footnote Full support
WebView on iOS – No support
WebView on iOS
footnote
footnote See bug 234009
color input
Chrome – Full support
Chrome 99 (Release date: 2022-03-01)
footnote Full support
Edge – Full support
Edge 99 (Release date: 2022-03-03)
footnote Full support
Firefox – Full support
Firefox 101 (Release date: 2022-05-31)
footnote Full support
Opera – Full support
Opera 85 (Release date: 2022-03-23)
footnote Full support
Safari – Full support
Safari 16 (Release date: 2022-09-12)
footnote Full support
Chrome Android – Full support
Chrome Android 99 (Release date: 2022-03-01)
footnote Full support
Firefox for Android – Full support
Firefox for Android 101 (Release date: 2022-05-31)
footnote Full support
Opera Android – Full support
Opera Android 68 (Release date: 2022-03-30)
footnote Full support
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – Full support
Samsung Internet 18 (Release date: 2022-08-08)
footnote Full support
WebView Android – Full support
WebView Android 99 (Release date: 2022-03-01)
footnote Full support
WebView on iOS – No support
WebView on iOS
footnote No support
datalist input
Chrome – Full support
Chrome 99 (Release date: 2022-03-01)
footnote Full support
Edge – Full support
Edge 99 (Release date: 2022-03-03)
footnote Full support
Firefox – Full support
Firefox 149 (Release date: 2026-03-24)
footnote Full support
Opera – Full support
Opera 85 (Release date: 2022-03-23)
footnote Full support
Safari – Preview support
Safari TP
footnote Preview browser support
Chrome Android – Full support
Chrome Android 99 (Release date: 2022-03-01)
footnote Full support
Firefox for Android – No support
Firefox for Android
footnote
footnote See bug 1535985
Opera Android – Full support
Opera Android 68 (Release date: 2022-03-30)
footnote Full support
Safari on iOS – No support
Safari on iOS
footnote
footnote See bug 261703
Samsung Internet – Full support
Samsung Internet 18 (Release date: 2022-08-08)
footnote Full support
WebView Android – Full support
WebView Android 99 (Release date: 2022-03-01)
footnote Full support
WebView on iOS – No support
WebView on iOS
footnote
footnote See bug 261703
date input
Chrome – Full support
Chrome 99 (Release date: 2022-03-01)
footnote Full support
Edge – Full support
Edge 99 (Release date: 2022-03-03)
footnote Full support
Firefox – Full support
Firefox 101 (Release date: 2022-05-31)
footnote Full support
Opera – Full support
Opera 85 (Release date: 2022-03-23)
footnote Full support
Safari – Full support
Safari 17.4 (Release date: 2024-03-05)
footnote Full support
Chrome Android – Full support
Chrome Android 99 (Release date: 2022-03-01)
footnote Full support
Firefox for Android – Full support
Firefox for Android 101 (Release date: 2022-05-31)
footnote Full support
Opera Android – Full support
Opera Android 68 (Release date: 2022-03-30)
footnote Full support
Safari on iOS – No support
Safari on iOS
footnote
footnote See bug 261703
Samsung Internet – Full support
Samsung Internet 18 (Release date: 2022-08-08)
footnote Full support
WebView Android – Full support
WebView Android 99 (Release date: 2022-03-01)
footnote Full support
WebView on iOS – No support
WebView on iOS
footnote
footnote See bug 261703
datetime-local input
Chrome – Full support
Chrome 99 (Release date: 2022-03-01)
footnote Full support
Edge – Full support
Edge 99 (Release date: 2022-03-03)
footnote Full support
Firefox – Full support
Firefox 101 (Release date: 2022-05-31)
footnote Full support
Opera – Full support
Opera 85 (Release date: 2022-03-23)
footnote Full support
Safari – Full support
Safari 17.4 (Release date: 2024-03-05)
footnote Full support
Chrome Android – Full support
Chrome Android 99 (Release date: 2022-03-01)
footnote Full support
Firefox for Android – Full support
Firefox for Android 101 (Release date: 2022-05-31)
footnote Full support
Opera Android – Full support
Opera Android 68 (Release date: 2022-03-30)
footnote Full support
Safari on iOS – No support
Safari on iOS
footnote
footnote See bug 261703
Samsung Internet – Full support
Samsung Internet 18 (Release date: 2022-08-08)
footnote Full support
WebView Android – Full support
WebView Android 99 (Release date: 2022-03-01)
footnote Full support
WebView on iOS – No support
WebView on iOS
footnote
footnote See bug 261703
file input
Chrome – Full support
Chrome 99 (Release date: 2022-03-01)
footnote Full support
Edge – Full support
Edge 99 (Release date: 2022-03-03)
footnote Full support
Firefox – Full support
Firefox 101 (Release date: 2022-05-31)
footnote Full support
Opera – Full support
Opera 85 (Release date: 2022-03-23)
footnote Full support
Safari – Full support
Safari 16 (Release date: 2022-09-12)
footnote Full support
Chrome Android – Full support
Chrome Android 99 (Release date: 2022-03-01)
footnote Full support
Firefox for Android – Full support
Firefox for Android 101 (Release date: 2022-05-31)
footnote Full support
Opera Android – Full support
Opera Android 68 (Release date: 2022-03-30)
footnote Full support
Safari on iOS – Full support
Safari on iOS 16 (Release date: 2022-09-12)
footnote Full support
Samsung Internet – Full support
Samsung Internet 18 (Release date: 2022-08-08)
footnote Full support
WebView Android – Full support
WebView Android 99 (Release date: 2022-03-01)
footnote Full support
WebView on iOS – Full support
WebView on iOS 16 (Release date: 2022-09-12)
footnote Full support
month input
Chrome – Full support
Chrome 99 (Release date: 2022-03-01)
footnote Full support
Edge – Full support
Edge 99 (Release date: 2022-03-03)
footnote Full support
Firefox – No support
Firefox
footnote No support
Opera – Full support
Opera 85 (Release date: 2022-03-23)
footnote Full support
Safari – No support
Safari
footnote
footnote See bug 234009
Chrome Android – Full support
Chrome Android 99 (Release date: 2022-03-01)
footnote Full support
Firefox for Android – No support
Firefox for Android 101 – 111 (Release date: 2022-05-31)
footnote Removed in 112 and later
Firefox for Android – Full support
Firefox for Android 121 (Release date: 2023-12-19)
footnote Full support
Opera Android – Full support
Opera Android 68 (Release date: 2022-03-30)
footnote Full support
Safari on iOS – No support
Safari on iOS
footnote
footnote See bug 234009
Samsung Internet – Full support
Samsung Internet 18 (Release date: 2022-08-08)
footnote Full support
WebView Android – Full support
WebView Android 99 (Release date: 2022-03-01)
footnote Full support
WebView on iOS – No support
WebView on iOS
footnote
footnote See bug 234009
time input
Chrome – Full support
Chrome 99 (Release date: 2022-03-01)
footnote Full support
Edge – Full support
Edge 99 (Release date: 2022-03-03)
footnote Full support
Firefox – No support
Firefox
footnote No support
Opera – Full support
Opera 85 (Release date: 2022-03-23)
footnote Full support
Safari – Full support
Safari 16 (Release date: 2022-09-12)
footnote Full support
Chrome Android – Full support
Chrome Android 99 (Release date: 2022-03-01)
footnote Full support
Firefox for Android – Full support
Firefox for Android 101 (Release date: 2022-05-31)
footnote Full support
Opera Android – Full support
Opera Android 68 (Release date: 2022-03-30)
footnote Full support
Safari on iOS – No support
Safari on iOS
footnote
footnote See bug 261703
Samsung Internet – Full support
Samsung Internet 18 (Release date: 2022-08-08)
footnote Full support
WebView Android – Full support
WebView Android 99 (Release date: 2022-03-01)
footnote Full support
WebView on iOS – No support
WebView on iOS
footnote
footnote See bug 261703
week input
Chrome – Full support
Chrome 99 (Release date: 2022-03-01)
footnote Full support
Edge – Full support
Edge 99 (Release date: 2022-03-03)
footnote Full support
Firefox – No support
Firefox
footnote No support
Opera – Full support
Opera 85 (Release date: 2022-03-23)
footnote Full support
Safari – No support
Safari
footnote
footnote See bug 234009
Chrome Android – Full support
Chrome Android 99 (Release date: 2022-03-01)
footnote Full support
Firefox for Android – No support
Firefox for Android 101 – 111 (Release date: 2022-05-31)
footnote Removed in 112 and later
Firefox for Android – Full support
Firefox for Android 121 (Release date: 2023-12-19)
footnote Full support
Opera Android – Full support
Opera Android 68 (Release date: 2022-03-30)
footnote Full support
Safari on iOS – No support
Safari on iOS
footnote
footnote See bug 234009
Samsung Internet – Full support
Samsung Internet 18 (Release date: 2022-08-08)
footnote Full support
WebView Android – Full support
WebView Android 99 (Release date: 2022-03-01)
footnote Full support
WebView on iOS – No support
WebView on iOS
footnote
footnote See bug 234009

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
In development. Supported in a pre-release version.
In development. Supported in a pre-release version.
No support
No support
See implementation notes.
Has more compatibility info.

See also