Getting Started
Components52
- Accordion
- Alert
- Alert Dialog
- Attachment
- Badge
- Breadcrumb
- Bubble
- Button
- Button Group
- Calendar
- Card
- Checkbox
- Collapsible
- Command
- Context Menu
- Data Table
- Dialog
- Drawer
- Dropdown Menu
- Empty
- Field
- Hover Card
- Input
- Input Group
- Item
- Kbd
- Label
- Marker
- Menubar
- Message
- Message Scroller
- Pagination
- Popover
- Progress
- Questionnaire
- Radio Group
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Sonner
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Toggle
- Toggle Group
- Tooltip
A window overlaid on either the primary window or another dialog window, rendering the content underneath inert.
import { Button } from "@/components/ui/button"
import {
Dialog,
DialogContent,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog"
import { Input } from "@/components/ui/input"
export function DialogDemo() {
return (
<Dialog>
<DialogTrigger render={<Button variant="secondary" />}>
Sign in
</DialogTrigger>
<DialogContent showCloseButton={false}>
<DialogHeader className="items-center">
<DialogTitle>Sign in to Acme</DialogTitle>
</DialogHeader>
<Input type="email" placeholder="you@studio.com" aria-label="Email" />
<DialogFooter>
<Button>Continue</Button>
</DialogFooter>
</DialogContent>
</Dialog>
)
}Installation#
pnpm dlx shadcn@latest add https://ui.ikramhasan.com/r/dialog.json
Usage#
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog"<Dialog>
<DialogTrigger>Open</DialogTrigger>
<DialogContent>
<DialogHeader>
<DialogTitle>Are you absolutely sure?</DialogTitle>
<DialogDescription>
This action cannot be undone. This will permanently delete your account
and remove your data from our servers.
</DialogDescription>
</DialogHeader>
</DialogContent>
</Dialog>Examples#
Form#
import { Button } from "@/components/ui/button"
import {
Dialog,
DialogClose,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
export function DialogForm() {
return (
<Dialog>
<DialogTrigger render={<Button variant="secondary" />}>
Edit workspace
</DialogTrigger>
<DialogContent>
<DialogHeader>
<DialogTitle>Edit workspace</DialogTitle>
<DialogDescription>
Changes apply to everyone in the workspace.
</DialogDescription>
</DialogHeader>
<div className="flex flex-col gap-4">
<div className="flex flex-col gap-1.5">
<Label htmlFor="ws-name">Name</Label>
<Input id="ws-name" defaultValue="Acme" />
</div>
<div className="flex flex-col gap-1.5">
<Label htmlFor="ws-url">URL</Label>
<Input id="ws-url" defaultValue="acme.techshoi.app" />
</div>
</div>
<DialogFooter>
<DialogClose render={<Button variant="outline" />}>
Cancel
</DialogClose>
<Button>Save changes</Button>
</DialogFooter>
</DialogContent>
</Dialog>
)
}Without footer#
import { Button } from "@/components/ui/button"
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog"
export function DialogWithoutFooter() {
return (
<Dialog>
<DialogTrigger render={<Button variant="secondary" />}>
Keyboard shortcuts
</DialogTrigger>
<DialogContent>
<DialogHeader>
<DialogTitle>Keyboard shortcuts</DialogTitle>
<DialogDescription>
Press ⌘K anywhere to open quick actions, and ⌘/ to see this list
again.
</DialogDescription>
</DialogHeader>
</DialogContent>
</Dialog>
)
}Footer close button#
import { Button } from "@/components/ui/button"
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog"
export function DialogFooterCloseButton() {
return (
<Dialog>
<DialogTrigger render={<Button variant="secondary" />}>
What's new
</DialogTrigger>
<DialogContent>
<DialogHeader>
<DialogTitle>What's new</DialogTitle>
<DialogDescription>
Stores now sync every hour, and you can pin chats to the sidebar.
</DialogDescription>
</DialogHeader>
<DialogFooter showCloseButton />
</DialogContent>
</Dialog>
)
}API Reference#
Dialog is built on the Base UI Dialog primitive. See the Base UI documentation for every prop.