Published at
Updated at
Reading time
1min

Not too long ago, we finally got cross-browser-supported date input elements. With Safari joining the party, we're now all green on the browser support front to show native date pickers everywhere.

MDN Compat Data (source)
Browser support info for `type="date"`
chromechrome_androidedgefirefoxfirefox_androidsafarisafari_iossamsunginternet_androidwebview_android
202012575714.151.520

There was still one piece missing, though. If now all major browsers support native date pickers, developers asked for a method to programmatically open it.

Say hello to elem.showPicker()!

const button = document.querySelector("button");
const dateInput = document.querySelector("input");
button.addEventListener("click", async () => {
  try {
    await dateInput.showPicker();
    // A date picker is shown.
  } catch (error) {
    // Use external library when this fails.
  }
});

The new method will be available in Chromium 99+. But it's not only useful when dealing with date inputs. showPicker enables you to open browser pickers of type date, month, week, time, datetime-local, color and file, too! ๐Ÿ‘

MDN Compat Data (source)
Browser support info for dateInput.showPicker()
chromechrome_androidedgefirefoxfirefox_androidsafarisafari_iossamsunginternet_androidwebview_android
999999101101161618.099

Webkit and Firefox also showed interest in implementing it:

I just love it when we get new DOM methods!

Update on Sep 12: with Safari 16 showPicker is supported across all major browsers! ๐ŸŽ‰

If you enjoyed this article...

Join 5.5k readers and learn something new every week with Web Weekly.

Web Weekly โ€” Your friendly Web Dev newsletter
Reply to this post and share your thoughts via good old email.
Stefan standing in the park in front of a green background

About Stefan Judis

Frontend nerd with over ten years of experience, freelance dev, "Today I Learned" blogger, conference speaker, and Open Source maintainer.

Related Topics

Related Articles