Popover API Playground
Build native popovers and copy the exact HTML, CSS and JS.
Input
1 line · 13 charsResult
24 lines · 570 charsThe Popover API Playground renders real popovers from the attributes you configure — no simulations. Toggle auto versus manual to see light dismiss, choose a popovertarget trigger or a showPopover() call, style the ::backdrop, add a nested child popover, and copy HTML, CSS and JS that mirror exactly what the stage shows. The event log records toggle transitions so the difference between opening, closing and idempotent actions is visible.
Examples
mode=auto, trigger=toggle<button popovertarget="demo">Toggle</button>
<div id="demo" popover="auto">Content</div>The declarative form is the shortest working auto popover.
mode=manual, trigger=jsdocument.getElementById("demo").togglePopover()Manual popovers need an explicit call since light dismiss does not close them.
backdrop blur=4px#demo::backdrop { backdrop-filter: blur(4px); }Backdrop effects appear only while the popover is shown.
About this tool
This playground is a hands-on reference for the native Popover API. Every control maps to a real attribute or CSS rule, and the code panes are generated from the same configuration that renders the stage, so what you copy is what you saw.
Use it to understand auto versus manual behavior: auto popovers support light dismiss and Escape, only one sibling auto popover is open at a time, and closing a parent closes its nested auto children. Manual popovers stay open until an explicit action closes them.
User content is inserted as text, never as innerHTML, so pasted markup cannot execute scripts. The tool runs entirely in your browser.
What this tool does not do
- Older browsers without the Popover API show a support banner; generated code still copies but the stage degrades gracefully.
- CSS anchor positioning is not implemented; the popover uses fixed placement presets.
- jsdom does not implement the top layer or popover events, so toggle logging is verified in a real browser rather than unit tests.
How to use this tool
Choose the mode
Select auto or manual. Auto supports light dismiss and Escape; manual requires an explicit hide action.
Configure the trigger
Use a popovertarget button with show, hide or toggle action, or choose the JS trigger mode to get a showPopover() call.
Style and nest
Set backdrop color, blur and transition, and optionally add a nested child popover to see native stacking.
Copy the code
Switch between the HTML, CSS and JS tabs and copy each snippet. The JS tab is emitted only for JS trigger mode.
Use cases
Replace a tooltip library
Prototype a native, accessible tooltip with no dependency, then copy the minimal markup and CSS into your app.
Teach the platform
Demonstrate light dismiss, nesting and the toggle event live in a workshop without building a demo app.
Design-system primitives
Compare auto and manual semantics before baking a popover component into your design system.
Attribute reference
| Attribute / API | Values |
|---|---|
| popover | auto | manual |
| popovertarget | element id |
| popovertargetaction | show | hide | toggle |
| ::backdrop | CSS |
| toggle event | oldState / newState |
The JS tab is generated only when the JS trigger mode is selected; declarative mode needs no script at all.
Common mistakes
Mistake:Expecting manual popovers to close on outside click.
Fix:That is correct auto behavior only. Manual popovers ignore light dismiss and Escape; call hidePopover() or use a hide trigger.
Mistake:Using popover where a modal dialog is needed.
Fix:Popovers are non-modal by default and do not trap focus or make the rest of the page inert. Use the dialog element for modals.
Mistake:Assuming close transitions work with display alone.
Fix:Closing exit animations need transition-behavior: allow-discrete on overlay and display, plus @starting-style for the opening state.
Frequently asked questions
What is the difference between popover auto and manual?
An auto popover supports light dismiss: clicking outside it or pressing Escape closes it, and opening another auto popover closes the first. A manual popover ignores both and stays open until your code hides it or a hide trigger is used. Auto also closes nested auto children when the parent closes.
Does popover replace dialog?
No. A popover is non-modal by default: the rest of the page stays interactive and focus is not trapped. Use the dialog element with showModal() when you need a modal that makes the rest of the page inert and traps focus.
How does light dismiss work?
In auto mode the browser closes the popover when you click or focus outside it, or press Escape. The toggle event fires with oldState and newState so you can react. Manual mode deliberately does not light-dismiss.
Can popovers nest?
Yes. A popover inside another popover opens above it in the top layer. With auto mode, closing the parent also closes its nested auto children; with manual mode you must close them yourself.
How do I style the backdrop?
Use the ::backdrop pseudo-element on the popover, for example #p::backdrop { background: rgba(0,0,0,.45); backdrop-filter: blur(3px); }. It applies only while the popover is shown. Smooth open and close transitions additionally need @starting-style and allow-discrete on display and overlay.
References & standards
Related tools
.env Secret Safety Linter
Validate .env syntax and spot likely leaked credentials or placeholder secrets.
.gitattributes Generator
Build .gitattributes rules for line endings, Git LFS, GitHub linguist marks and merge drivers — with a one-line explanation for every rule.
.htaccess Generator
Build an Apache .htaccess — HTTPS redirects, rewrites, error pages, security headers, and basic auth
2D Fluid Dynamics & Particle Physics Sandbox
A physics playground with two engines sharing one canvas. The fluid mode runs a real Eulerian Navier-Stokes solver — semi-Lagrangian advection, explicit diffusion, Jacobi pressure projection and vorticity confinement — that you paint with dye and velocity using mouse or touch. The particle mode is a damped Verlet N-body engine with gravity wells, Coulomb attractors and repulsors, spring links, wall restitution and elastic circle collisions. Particle counts adapt to the device (100k target on WebGL2 desktop, 2k-5k on CPU fallback), and every configuration exports as runnable code: a Matter.js world, a PixiJS ticker setup, or a standalone vanilla Canvas engine.
A/B Test Sample Size Calculator
Compute required sample size per variant and test duration from baseline conversion rate, minimum detectable effect, alpha and power.
ABA Routing Number Validator
Validate 9-digit US ABA routing numbers with 3-7-1 Mod-10 breakdown.