GooseUI

Components

Dialog


Dialog presents content in a modal layer above the page. The native dialog element manages focus and the Escape key. Its state can be controlled or uncontrolled. Animations respect reduced motion preferences.

Browser support

<dialog>

Native modal window.

Your browser:
@starting-style

Entry animation.

Your browser:
transition-behavior

Exit animation.

Your browser:

Preview

Profile settings

Update your settings and save your changes.

Installation

npx shadcn@latest add @gooseui/dialog
pnpm dlx shadcn@latest add @gooseui/dialog
yarn dlx shadcn@latest add @gooseui/dialog
bunx --bun shadcn@latest add @gooseui/dialog

Usage

import { Dialog, DialogTrigger, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter, DialogClose } from "@/components/ui/dialog"
import { Button } from "@/components/ui/button"

<Dialog>
  <DialogTrigger asChild><Button>Open</Button></DialogTrigger>
  <DialogContent>
    <DialogHeader><DialogTitle>Profile settings</DialogTitle><DialogDescription>Update your settings.</DialogDescription></DialogHeader>
    <DialogFooter><DialogClose asChild><Button>Close</Button></DialogClose></DialogFooter>
  </DialogContent>
</Dialog>

Examples

Basic

Profile settings

Update your settings and save your changes.

import { Dialog, DialogTrigger, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter, DialogClose } from "@/components/ui/dialog"
import { Button } from "@/components/ui/button"

<Dialog>
  <DialogTrigger asChild><Button>Open</Button></DialogTrigger>
  <DialogContent>
    <DialogHeader><DialogTitle>Profile settings</DialogTitle><DialogDescription>Update your settings.</DialogDescription></DialogHeader>
    <DialogFooter><DialogClose asChild><Button>Close</Button></DialogClose></DialogFooter>
  </DialogContent>
</Dialog>

With a form

Profile settings

Update your settings and save your changes.

<Dialog>
  <DialogTrigger asChild><Button>Edit profile</Button></DialogTrigger>
  <DialogContent>
    <DialogHeader><DialogTitle>Edit profile</DialogTitle><DialogDescription>Update your name.</DialogDescription></DialogHeader>
    <form onSubmit={handleSubmit}><label>Name <Input name="name" /></label><Button type="submit">Save</Button></form>
  </DialogContent>
</Dialog>

Controlled

Profile settings

Update your settings and save your changes.

const [open, setOpen] = React.useState(false)

<Dialog open={open} onOpenChange={setOpen}>
  <DialogTrigger asChild><Button>Open</Button></DialogTrigger>
  <DialogContent><DialogTitle>Settings</DialogTitle><DialogDescription>Manage your settings.</DialogDescription></DialogContent>
</Dialog>

Props

PropTypeDefaultDescription
openboolean-Controlled open state.
defaultOpenbooleanfalseInitial open state.
onOpenChange(open: boolean) => void-Called when open state changes.
asChildbooleanfalseComposes Trigger or Close with its child.
showCloseButtonbooleantrueShows the close button.
classNamestring-Additional CSS classes.