- Accordion
- Alert
- Alert Dialog
- Aspect Ratio
- Attachment
- Autocomplete
- Avatar
- Badge
- Breadcrumb
- Bubble
- Button
- Calendar
- Card
- Carousel
- Chart
- Checkbox
- Checkbox Group
- Collapsible
- Combobox
- Command
- Context Menu
- Date Picker
- Dialog
- Drawer
- Dropdown Menu
- Empty
- Field
- Fieldset
- Form
- Frame
- Group
- Input
- Input Group
- Kbd
- Label
- Menu
- Menubar
- Message
- Meter
- Number Field
- OTP Field
- Pagination
- Popover
- Preview Card
- Progress
- Questionnaire
- Radio Group
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Toggle
- Toggle Group
- Toolbar
- Tooltip
- Artifact
- Audio Player
- Canvas
- Chain of Thought
- Checkpoint
- Code Block
- Commit
- Connection
- Context
- Controls
- Edge
- Environment Variables
- Mic Selector
- Model Selector
- Node
- Node Toolbar
- Open in Chat
- Panel
- Plan
- Prompt Input
- Queue
- Reasoning
- Sandbox
- Schema Display
- Shimmer
- Snippet
- Sources
- Speech Input
- Stack Trace
- Suggestion
- Tool
- Transcription
- Web Preview
Dialog
A popup that opens on top of the entire page.
import { Button } from "@/components/ui/button";
import {
Dialog,
DialogClose,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog";
import { Field, FieldLabel } from "@/components/ui/field";
import { Input } from "@/components/ui/input";
export default function Particle() {
return (
<Dialog>
<DialogTrigger render={<Button variant="outline" />}>Open Dialog</DialogTrigger>
<DialogContent className="sm:max-w-sm">
<DialogHeader>
<DialogTitle>Edit profile</DialogTitle>
<DialogDescription>
Make changes to your profile here. Click save when you're done.
</DialogDescription>
</DialogHeader>
<form className="contents">
<div className="grid gap-4">
<Field>
<FieldLabel>Name</FieldLabel>
<Input defaultValue="Margaret Welsh" type="text" />
</Field>
<Field>
<FieldLabel>Username</FieldLabel>
<Input defaultValue="@maggie.welsh" type="text" />
</Field>
</div>
<DialogFooter>
<DialogClose render={<Button variant="ghost" />}>Cancel</DialogClose>
<Button type="submit">Save</Button>
</DialogFooter>
</form>
</DialogContent>
</Dialog>
);
}
Installation
pnpm dlx shadcn@latest add @frontal-labs/dialog
Usage
import {
Dialog,
DialogClose,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog";<Dialog>
<DialogTrigger>Open Dialog</DialogTrigger>
<DialogContent>
<DialogHeader>
<DialogTitle>Dialog Title</DialogTitle>
<DialogDescription>Dialog Description</DialogDescription>
</DialogHeader>
<div>Content</div>
<DialogFooter>
<DialogClose>Close</DialogClose>
</DialogFooter>
</DialogContent>
</Dialog>API Reference
Dialog
Root component. Alias for Dialog.Root from Base UI.
DialogTrigger
Trigger button that opens the dialog. Alias for Dialog.Trigger from Base UI.
DialogContent
Popup container that displays the dialog content. Renders the portal and the overlay internally, so DialogPortal and DialogOverlay do not need to be composed by hand.
| Prop | Type | Default | Description |
|---|---|---|---|
showCloseButton | boolean | true | When true, displays a close button in the top-right corner |
overlayClassName | string | - | Additional CSS classes forwarded to the internal DialogOverlay |
dark | boolean | true | Renders the surface with the dark palette by applying .dark to the portal element |
All other props from Dialog.Popup are supported.
The dark prop
The dialog renders with the dark palette by default. Pass dark={false} when it should follow the ambient theme instead — next-themes sets dark on <html> and the portal lands in document.body, inside it, so the surface can pick up the ambient theme once dark is turned off.
If the dialog is opened from a .dark region scoped mid-page, which a portal does escape, rendering into the scoped node keeps inheritance intact in both directions without needing this prop at all.
<DialogContent dark>...</DialogContent>DialogHeader
Container for the dialog title and description.
DialogFooter
Footer section for action buttons. Renders with a top border and a muted background.
| Prop | Type | Default | Description |
|---|---|---|---|
showCloseButton | boolean | false | When true, appends a Close button rendered with the outline button variant |
Example:
<DialogFooter>
<DialogClose>Cancel</DialogClose>
<Button>Save</Button>
</DialogFooter>
// With an appended close button
<DialogFooter showCloseButton />DialogTitle
Title component. Alias for Dialog.Title from Base UI.
DialogDescription
Description component. Alias for Dialog.Description from Base UI.
DialogClose
Close button component. Alias for Dialog.Close from Base UI.
DialogPortal
Portal component for rendering outside the DOM hierarchy. Alias for Dialog.Portal from Base UI. Rendered internally by DialogContent.
DialogOverlay
Backdrop component. Styled wrapper for Dialog.Backdrop from Base UI. Rendered internally by DialogContent.
Examples
Open from a Menu
"use client";
import { useState } from "react";
import { Button } from "@/components/ui/button";
import {
Dialog,
DialogClose,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
} from "@/components/ui/dialog";
import { Menu, MenuItem, MenuPopup, MenuTrigger } from "@/components/ui/menu";
export default function Particle() {
const [dialogOpen, setDialogOpen] = useState(false);
return (
<>
<Menu>
<MenuTrigger render={<Button variant="outline" />}>Open menu</MenuTrigger>
<MenuPopup align="start">
<MenuItem onClick={() => setDialogOpen(true)}>Open dialog</MenuItem>
</MenuPopup>
</Menu>
<Dialog onOpenChange={setDialogOpen} open={dialogOpen}>
<DialogContent>
<DialogHeader>
<DialogTitle>Settings</DialogTitle>
<DialogDescription>Change your preferences</DialogDescription>
</DialogHeader>
<DialogFooter>
<DialogClose render={<Button variant="ghost" />}>Close</DialogClose>
</DialogFooter>
</DialogContent>
</Dialog>
</>
);
}
Dialog with a Form
import { Button } from "@/components/ui/button";
import {
Dialog,
DialogClose,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog";
import { Field, FieldLabel } from "@/components/ui/field";
import { Input } from "@/components/ui/input";
export default function Particle() {
return (
<Dialog>
<DialogTrigger render={<Button variant="outline" />}>Open Dialog</DialogTrigger>
<DialogContent className="sm:max-w-sm">
<DialogHeader>
<DialogTitle>Edit profile</DialogTitle>
<DialogDescription>
Make changes to your profile here. Click save when you're done.
</DialogDescription>
</DialogHeader>
<form className="contents">
<div className="grid gap-4">
<Field>
<FieldLabel>Name</FieldLabel>
<Input defaultValue="Margaret Welsh" type="text" />
</Field>
<Field>
<FieldLabel>Username</FieldLabel>
<Input defaultValue="@maggie.welsh" type="text" />
</Field>
</div>
<DialogFooter>
<DialogClose render={<Button variant="ghost" />}>Cancel</DialogClose>
<Button type="submit">Save</Button>
</DialogFooter>
</form>
</DialogContent>
</Dialog>
);
}
Dialog with scroll inside
import { Button } from "@/components/ui/button";
import {
Dialog,
DialogClose,
DialogContent,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog";
export default function Particle() {
return (
<Dialog>
<DialogTrigger render={<Button variant="outline" />}>Terms & Conditions</DialogTrigger>
<DialogContent className="sm:max-w-md" showCloseButton={false}>
<DialogHeader>
<DialogTitle>Terms & Conditions</DialogTitle>
</DialogHeader>
<div>
<div className="flex flex-col gap-4 [&_strong]:font-semibold [&_strong]:text-foreground">
<div className="flex flex-col gap-4">
<div className="flex flex-col gap-1">
<p>
<strong>Acceptance of Terms</strong>
</p>
<p>
By accessing and using this website, users agree to comply with and be bound by
these Terms of Service. Users who do not agree with these terms should discontinue
use of the website immediately.
</p>
</div>
<div className="flex flex-col gap-1">
<p>
<strong>User Account Responsibilities</strong>
</p>
<p>
Users are responsible for maintaining the confidentiality of their account
credentials. Any activities occurring under a user's account are the sole
responsibility of the account holder. Users must notify the website administrators
immediately of any unauthorized account access.
</p>
</div>
<div className="flex flex-col gap-1">
<p>
<strong>Content Usage and Restrictions</strong>
</p>
<p>
The website and its original content are protected by intellectual property laws.
Users may not reproduce, distribute, modify, create derivative works, or
commercially exploit any content without explicit written permission from the
website owners.
</p>
</div>
<div className="flex flex-col gap-1">
<p>
<strong>Limitation of Liability</strong>
</p>
<p>
The website provides content “as is” without any warranties. The
website owners shall not be liable for direct, indirect, incidental,
consequential, or punitive damages arising from user interactions with the
platform.
</p>
</div>
<div className="flex flex-col gap-1">
<p>
<strong>User Conduct Guidelines</strong>
</p>
<ul className="list-disc pl-6">
<li>Not upload harmful or malicious content</li>
<li>Respect the rights of other users</li>
<li>Avoid activities that could disrupt website functionality</li>
<li>Comply with applicable local and international laws</li>
</ul>
</div>
<div className="flex flex-col gap-1">
<p>
<strong>Modifications to Terms</strong>
</p>
<p>
The website reserves the right to modify these terms at any time. Continued use of
the website after changes constitutes acceptance of the new terms.
</p>
</div>
<div className="flex flex-col gap-1">
<p>
<strong>Termination Clause</strong>
</p>
<p>
The website may terminate or suspend user access without prior notice for
violations of these terms or for any other reason deemed appropriate by the
administration.
</p>
</div>
<div className="flex flex-col gap-1">
<p>
<strong>Governing Law</strong>
</p>
<p>
These terms are governed by the laws of the jurisdiction where the website is
primarily operated, without regard to conflict of law principles.
</p>
</div>
</div>
</div>
</div>
<DialogFooter>
<DialogClose render={<Button variant="ghost" />}>Cancel</DialogClose>
<Button type="button">I agree</Button>
</DialogFooter>
</DialogContent>
</Dialog>
);
}
Nested Dialogs
import { Button } from "@/components/ui/button";
import {
Dialog,
DialogClose,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog";
import { Field, FieldLabel } from "@/components/ui/field";
import { Input } from "@/components/ui/input";
export default function Particle() {
return (
<Dialog>
<DialogTrigger render={<Button variant="outline" />}>Open parent</DialogTrigger>
<DialogContent showCloseButton={false}>
<DialogHeader>
<DialogTitle>Manage team member</DialogTitle>
<DialogDescription>View and manage a user in your team.</DialogDescription>
</DialogHeader>
<div className="grid gap-4">
<div className="grid gap-1">
<p className="text-muted-foreground text-sm">Name</p>
<p className="font-medium text-sm">Bora Baloglu</p>
</div>
<div className="grid gap-1">
<p className="text-muted-foreground text-sm">Email</p>
<p className="font-medium text-sm">bora@example.com</p>
</div>
</div>
<DialogFooter>
<Dialog>
<DialogTrigger render={<Button variant="outline" />}>Edit details</DialogTrigger>
<DialogContent showCloseButton={false}>
<DialogHeader>
<DialogTitle>Edit details</DialogTitle>
<DialogDescription>
Make changes to the member's information.
</DialogDescription>
</DialogHeader>
<div className="grid gap-4">
<Field>
<FieldLabel>Name</FieldLabel>
<Input defaultValue="Bora Baloglu" type="text" />
</Field>
<Field>
<FieldLabel>Email</FieldLabel>
<Input defaultValue="bora@example.com" type="text" />
</Field>
</div>
<DialogFooter>
<DialogClose render={<Button variant="ghost" />}>Cancel</DialogClose>
<Button type="submit">Save changes</Button>
</DialogFooter>
</DialogContent>
</Dialog>
</DialogFooter>
</DialogContent>
</Dialog>
);
}
Close Confirmation
"use client";
import { useState } from "react";
import {
AlertDialog,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
} from "@/components/ui/alert-dialog";
import { Button } from "@/components/ui/button";
import {
Dialog,
DialogClose,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog";
import { Field } from "@/components/ui/field";
import { Textarea } from "@/components/ui/textarea";
export default function Particle() {
const [dialogOpen, setDialogOpen] = useState(false);
const [confirmOpen, setConfirmOpen] = useState(false);
const [value, setValue] = useState("");
return (
<Dialog
onOpenChange={(o) => {
if (!o && value) {
setConfirmOpen(true);
} else {
setDialogOpen(o);
}
}}
open={dialogOpen}
>
<DialogTrigger render={<Button variant="outline" />}>Compose</DialogTrigger>
<DialogContent showCloseButton={false}>
<DialogHeader>
<DialogTitle>New message</DialogTitle>
<DialogDescription>Type something and try closing.</DialogDescription>
</DialogHeader>
<form
className="contents"
onSubmit={(event) => {
event.preventDefault();
// Close the dialog when submitting
setDialogOpen(false);
}}
>
<div>
<Field>
<Textarea onChange={(e) => setValue(e.target.value)} value={value} />
</Field>
</div>
<DialogFooter>
<DialogClose render={<Button variant="ghost" />}>Cancel</DialogClose>
<Button
onClick={() => {
setValue("");
setDialogOpen(false);
}}
>
Send
</Button>
</DialogFooter>
</form>
</DialogContent>
{/* Confirmation dialog */}
<AlertDialog onOpenChange={setConfirmOpen} open={confirmOpen}>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Discard changes?</AlertDialogTitle>
<AlertDialogDescription>Your message will be lost.</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel render={<Button variant="ghost" />}>Go back</AlertDialogCancel>
<Button
onClick={() => {
setConfirmOpen(false);
setValue("");
setDialogOpen(false);
}}
>
Discard
</Button>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
</Dialog>
);
}