Components / component

Modal Dialog

v1.0.0 · premium

A modal dialog built on the native dialog element, with a scaling panel, a fading backdrop, and focus handled by the browser.

Modal Dialog demo

Implementation

A modal dialog built on the native dialog element, with a scaling panel, a fading backdrop, and focus handled by the browser.

Framework
React 19.3.1 with TypeScript
Motion
Native CSS and browser APIs. No GSAP required.
Available modes
build
Version
1.0.0 · published

Source code

Download source ZIP
export function DialogModal({ open, onClose, title, children, lockScroll = true, ink, paper, className }: {
  open: boolean;
  /** Called when the visitor presses Escape, clicks the backdrop, or activates an element with `data-dialog-close`. */

Quality evidence

Export tested in 2 consumer projects with chromium, firefox, webkit. Evidence recorded on .

Changelog

v1.0.0 · A modal dialog built on the native dialog element, with a scaling panel, a fading backdrop, and focus handled by the browser.

Frequently asked questions

Why is it built on the native dialog element?

The browser then provides the focus trap, the inert page behind it, Escape handling and returning focus to the trigger, all of which are hard to get right by hand.

What happens to scrolling behind the dialog?

The page is locked while the dialog is open and released when it closes. Pass lockScroll false if a scroll library handles it.