Skip to Content
glob.ui home
Components

Dialog

A modal dialog on the native `<dialog>` element. Focus moves in, Escape closes it, and focus returns to the trigger. Build your own modal on the same behaviour with `DialogContentBase`.

Client componentUses state or handlers, so it starts with "use client".
import { Dialog, DialogTrigger, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter, DialogClose } from "@glob-ui/dialog"

Preview

Edit profile

Make changes to your profile. Esc or a backdrop click closes it.

Examples

Controlled

Controlled with open and onOpenChange. closeOnOutsideClick={false} keeps the dialog open on a backdrop click.

Delete project?

This cannot be undone.

Last choice: none yet

Sizes

size is sm, md or lg.

Size sm

The panel width follows the size prop.

Size md

The panel width follows the size prop.

Size lg

The panel width follows the size prop.

API

Props are generated from the TypeScript types in the package source.

Dialog

Prop

Type

DialogTrigger

Prop

Type

DialogContent

Prop

Type

DialogClose

Prop

Type

Accessibility

Key or actionBehaviour
Enter, Space on the triggerOpens the dialog. Focus moves to the first focusable element inside.
Tab, Shift+TabCycle inside the dialog. Background content is inert.
EscapeCloses the dialog and returns focus to the trigger.
Backdrop clickCloses the dialog, unless closeOnOutsideClick is false.

ARIA. The dialog is named by DialogTitle (aria-labelledby) and described by DialogDescription (aria-describedby). Always include a title.

On this page