---
title: "Native Popover Element with HTML"
description: "The HTML Popover API builds tooltips, dropdowns and overlays without a JavaScript library. How to use it, what it returns and where browsers support it."
canonical: "https://www.trevorlasn.com/blog/native-popover-with-html"
author: "Trevor I. Lasn"
published: "2025-01-24"
last-updated: "2026-11-08"
topics: ["HTML"]
---

# Native Popover Element with HTML

The HTML Popover API builds tooltips, dropdowns and overlays without a JavaScript library. How to use it, what it returns and where browsers support it.

By Trevor I. Lasn · Published 2025-01-24 · Updated 2026-11-08 · https://www.trevorlasn.com/blog/native-popover-with-html

[Browser support for `popover` on webstatus.dev](https://webstatus.dev/features/popover)

Building overlay UI elements like tooltips and dropdowns has always required complex JavaScript libraries. The new HTML Popover API changes this with native browser support for floating elements.

## Update: Corrected Browser Support and Return Values

An earlier edit of this post said the Popover API was Baseline Widely available since April 2025. It is Baseline Newly available since January 2025, when Safari on iOS 18.3 started closing popovers on a tap outside them.

`togglePopover()` also returns a boolean rather than `undefined`: `true` if the popover is open after the call. Both statements below are now corrected. Sources: [webstatus.dev](https://webstatus.dev/features/popover) and [MDN](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/togglePopover).

The [Popover API](https://html.spec.whatwg.org/multipage/popover.html) introduces a new `popover` attribute that transforms any HTML element into a floating overlay. 

The browser handles all the complex positioning, stacking order, and focus management automatically. This means we can create interactive UI elements without wrestling with z-index, click-outside handling, or managing focus states.

```html title="index.html"
<button popovertarget="info">Toggle Popover</button>
<div id="info" popover>
  <p>Popover content appears above other elements</p>
</div>
```

We can control popovers through two modes: `auto` and `manual`

Auto popovers dismiss themselves when clicking outside or when another auto popover opens, perfect for simple tooltips or dropdowns. Manual popovers give us more control over their behavior, useful for complex dialogs or multi-step flows.

The JavaScript API provides three methods to control popovers programmatically: `showPopover()`, `hidePopover()`, and `togglePopover()`

These methods execute synchronously. `showPopover()` and `hidePopover()` return `undefined`, while `togglePopover()` returns `true` if the popover is open after the call and `false` otherwise. The API also provides the `:popover-open` CSS pseudo-class for styling popovers based on their visibility state.

The Popover API represents a significant step forward in web platform capabilities. Instead of relying on complex positioning libraries or managing overlay states manually, we now have a native solution that handles these challenges elegantly. This means simpler code, better performance, and improved accessibility out of the box.

```jsx title="PopoverDemo.jsx"
import React from 'react';

const PopoverDemo = () => (
  <div className="mx-auto max-w-xl mt-5 mb-5 ">
    <button 
      onClick={() => document.getElementById('settings').togglePopover()}
      className="px-4 py-2 bg-indigo-600 text-white rounded hover:bg-indigo-700 active:bg-indigo-700 transition"
    >
      Toggle Popover
    </button>
    
    <div 
      id="settings" 
      popover="auto" 
      className="p-6 rounded-lg shadow-lg bg-white dark:bg-gray-800 border dark:border-gray-700"
    >
      <div className="flex justify-between items-center mb-4">
        <p className="text-lg font-semibold dark:text-white">What is Lorem Ipsum?</p>
        <button 
          onClick={() => document.getElementById('settings').hidePopover()}
          className="text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200"
        >
          Close
        </button>
      </div>
      <p className="text-gray-600 dark:text-gray-300">
        Lorem Ipsum is simply dummy text of the printing and typesetting industry.
      </p>
    </div>
  </div>
);

export default PopoverDemo;
```

The Popover API is Baseline Newly Available (since January 2025) and supported across all major browsers, including Chrome 114+, Firefox 125+, Safari 17+ and Safari on iOS 18.3+. It's the standard way to create overlay UI elements on the web.
