- Accordion
- Alert
- Avatar
- Badge
- Breadcrumb
- Button
- Button Group
- Calendarnew
- Card
- Carousel
- Checkbox
- Chip
- Collapse
- Dialog
- Drawer
- Footer
- Gallery
- Icon Button
- Image
- Input
- List
- Mapnew
- Menu
- Navbar
- Pagination
- Popover
- Progress
- Radio
- Rating
- Select
- Sidebar
- Skeletonnew
- Slider
- Software Purchase Card
- Sonner / Toastnew
- Speed Dial
- Spinner
- Stepper
- Switch
- Table
- Tabs
- Textarea
- Timeline
- Tooltip
- Typography
- Video
import { X } from "lucide-react"
import { Button } from "@/components/ui/button"
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog"
export function DialogDemo() {
return (
<Dialog>
<DialogTrigger asChild>
<Button>Open</Button>
</DialogTrigger>
<DialogContent>
<DialogHeader>
<DialogTitle>Creative Tim UI</DialogTitle>
</DialogHeader>
<DialogDescription className="mt-2 mb-6">
Creative Tim UI is an open-source library that uses the power of
Tailwind CSS and React to help you build unique web projects faster
and easier. The stunning design inspired by Material Design is a
bonus! Get Creative Tim UI and take advantage of its free components
and features that will help you set up your web project quickly.
</DialogDescription>
<DialogFooter>
<Button variant="ghost" className="text-destructive">
Cancel
</Button>
<Button>Get Started</Button>
</DialogFooter>
</DialogContent>
</Dialog>
)
}
Installation
pnpm dlx @creative-tim/ui@latest add dialog
Usage
import DialogDemo from "@/components/dialog-demo"<DialogDemo />Examples
Dialog Long
A dialog with scrollable long content, demonstrating how to handle dialogs with extensive text content while maintaining a clean interface with proper overflow handling.
import { Button } from "@/components/ui/button"
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog"
export function DialogLong() {
return (
<Dialog>
<DialogTrigger asChild>
<Button>Long Dialog</Button>
</DialogTrigger>
<DialogContent className="max-h-[90vh]">
<DialogHeader>
<DialogTitle>Long Dialog</DialogTitle>
</DialogHeader>
<div className="max-h-[60vh] overflow-y-auto">
<DialogDescription className="h-full">
I've always had unwavering confidence in my abilities, and I
believe our thoughts and self-perception are the primary forces that
shape us. Many people limit themselves by their own self-doubt,
slowing their progress. Fortunately, I was raised with the belief
that I could achieve anything.
<br />
<br />
As we journey through life, we often encounter challenges that
harden our hearts. Pain, insults, broken trust, and betrayal can
make us hesitant to help others. Love can lead to heartbreak, and
time can distance us from family. These experiences can gradually
erode our optimism.
<br />
<br />
Life doesn't always place us where we want to be. We grow, make
mistakes, and strive to express ourselves and fulfill our dreams. If
we're fortunate enough to participate in life's journey,
we should cherish every moment. Regrettably, some only recognize the
value of a moment after it's passed.
<br />
<br />
One thing I've learned is that I can excel at anything I set my
mind to. My skill is my ability to learn. I'm here to learn, to
grow, and to inspire others to do the same. Don't fear making
mistakes; they teach us far more than compliments ever will.
Ultimately, what truly matters is how our actions inspire and
motivate others. Some will be ignited by our endeavors, while others
may be offended—it's all part of the process. I'm here to
pursue my dreams and encourage others to do the same.
<br />
<br />
Now is the time to embrace greatness without fear of judgment. Some
may resent those who shine brightly or stand out, but it's time
to be the best version of ourselves. Do you have faith in your
beliefs, even if you're the only one who does?
<br />
<br />
As we journey through life, we often encounter challenges that
harden our hearts. Pain, insults, broken trust, and betrayal can
make us hesitant to help others. Love can lead to heartbreak, and
time can distance us from family. These experiences can gradually
erode our optimism.
<br />
<br />
Life doesn't always place us where we want to be. We grow, make
mistakes, and strive to express ourselves and fulfill our dreams. If
we're fortunate enough to participate in life's journey,
we should cherish every moment. Regrettably, some only recognize the
value of a moment after it's passed.
<br />
<br />
One thing I've learned is that I can excel at anything I set my
mind to. My skill is my ability to learn. I'm here to learn, to
grow, and to inspire others to do the same. Don't fear making
mistakes; they teach us far more than compliments ever will.
Ultimately, what truly matters is how our actions inspire and
motivate others. Some will be ignited by our endeavors, while others
may be offended—it's all part of the process. I'm here to
pursue my dreams and encourage others to do the same.
<br />
<br />
Now is the time to embrace greatness without fear of judgment. Some
may resent those who shine brightly or stand out, but it's time
to be the best version of ourselves. Do you have faith in your
beliefs, even if you're the only one who does? As we journey
through life, we often encounter challenges that harden our hearts.
Pain, insults, broken trust, and betrayal can make us hesitant to
help others. Love can lead to heartbreak, and time can distance us
from family. These experiences can gradually erode our optimism.
<br />
<br />
Life doesn't always place us where we want to be. We grow, make
mistakes, and strive to express ourselves and fulfill our dreams. If
we're fortunate enough to participate in life's journey,
we should cherish every moment. Regrettably, some only recognize the
value of a moment after it's passed.
<br />
<br />
One thing I've learned is that I can excel at anything I set my
mind to. My skill is my ability to learn. I'm here to learn, to
grow, and to inspire others to do the same. Don't fear making
mistakes; they teach us far more than compliments ever will.
Ultimately, what truly matters is how our actions inspire and
motivate others. Some will be ignited by our endeavors, while others
may be offended—it's all part of the process. I'm here to
pursue my dreams and encourage others to do the same.
<br />
<br />
Now is the time to embrace greatness without fear of judgment. Some
may resent those who shine brightly or stand out, but it's time
to be the best version of ourselves. Do you have faith in your
beliefs, even if you're the only one who does?
</DialogDescription>
</div>
<DialogFooter>
<Button variant="ghost" className="text-destructive">
Cancel
</Button>
<Button>Confirm</Button>
</DialogFooter>
</DialogContent>
</Dialog>
)
}
Dialog Message
A dialog containing a message form with username input and textarea fields, perfect for creating messaging interfaces or contact forms within a modal.
import { Button } from "@/components/ui/button"
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
import { Textarea } from "@/components/ui/textarea"
export function DialogMessage() {
return (
<Dialog>
<DialogTrigger asChild>
<Button>Open Message</Button>
</DialogTrigger>
<DialogContent className="sm:max-w-md">
<DialogHeader>
<DialogTitle>New message to @</DialogTitle>
<DialogDescription>
Write the message and then click button.
</DialogDescription>
</DialogHeader>
<form action="#" className="mt-6">
<div className="mt-2 mb-4 space-y-1.5">
<Label htmlFor="username" className="font-semibold">
Username
</Label>
<Input
id="username"
type="text"
placeholder="Username"
className="w-full"
/>
</div>
<div className="w-full space-y-1.5">
<Label htmlFor="message" className="font-medium">
Message
</Label>
<Textarea id="message" placeholder="Your message..." />
</div>
<DialogFooter className="mt-4">
<Button type="button" variant="secondary">
Cancel
</Button>
<Button type="submit">Send Message</Button>
</DialogFooter>
</form>
</DialogContent>
</Dialog>
)
}
Dialog Notification
A notification-style dialog with a centered layout, icon, and call-to-action buttons, ideal for displaying important alerts or confirmations to users.
import { Bell } from "lucide-react"
import { Button } from "@/components/ui/button"
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog"
export function DialogNotification() {
return (
<Dialog>
<DialogTrigger asChild>
<Button>Open Notification</Button>
</DialogTrigger>
<DialogContent className="p-8 sm:max-w-md">
<DialogHeader className="text-center">
<DialogTitle className="text-center">
Your Attention is Required!
</DialogTitle>
<DialogDescription className="text-center">
Choose which card you want to connect
</DialogDescription>
</DialogHeader>
<div className="mt-12 flex flex-col items-center text-center">
<Bell className="mb-6 h-24 w-24" />
<h6 className="text-lg font-semibold">You should read this!</h6>
<p className="text-muted-foreground mt-2 text-center">
Many people limit themselves by their own self-doubt, slowing their
progress. Fortunately, I was raised with the belief that I could
achieve anything.
</p>
</div>
<DialogFooter className="mt-8 mb-1">
<Button variant="ghost" className="text-destructive">
Cancel
</Button>
<Button>Got it</Button>
</DialogFooter>
</DialogContent>
</Dialog>
)
}
Dialog Sizes
A demonstration of dialog size variations (XS, SM, MD, LG, XL, Screen) showing how dialogs can be customized to fit different content requirements and screen sizes.
import { Button } from "@/components/ui/button"
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog"
export function DialogSizes() {
return (
<div className="flex flex-col items-center justify-center gap-2">
<div className="flex items-center justify-center gap-2">
<Dialog>
<DialogTrigger asChild>
<Button>Open XS</Button>
</DialogTrigger>
<DialogContent className="sm:max-w-xs">
<DialogHeader>
<DialogTitle>Creative Tim UI</DialogTitle>
</DialogHeader>
<DialogDescription className="mt-2 mb-6">
Creative Tim UI is an open-source library that uses the power of
Tailwind CSS and React to help you build unique web projects
faster and easier. The stunning design inspired by Material Design
is a bonus! Get Creative Tim UI and take advantage of its free
components and features that will help you set up your web project
quickly.
</DialogDescription>
<DialogFooter>
<Button variant="ghost" className="text-destructive">
Cancel
</Button>
<Button>Get Started</Button>
</DialogFooter>
</DialogContent>
</Dialog>
<Dialog>
<DialogTrigger asChild>
<Button>Open SM</Button>
</DialogTrigger>
<DialogContent className="sm:max-w-md">
<DialogHeader>
<DialogTitle>Creative Tim UI</DialogTitle>
</DialogHeader>
<DialogDescription className="mt-2 mb-6">
Creative Tim UI is an open-source library that uses the power of
Tailwind CSS and React to help you build unique web projects
faster and easier. The stunning design inspired by Material Design
is a bonus! Get Creative Tim UI and take advantage of its free
components and features that will help you set up your web project
quickly.
</DialogDescription>
<DialogFooter>
<Button variant="ghost" className="text-destructive">
Cancel
</Button>
<Button>Get Started</Button>
</DialogFooter>
</DialogContent>
</Dialog>
<Dialog>
<DialogTrigger asChild>
<Button>Open MD</Button>
</DialogTrigger>
<DialogContent className="sm:max-w-lg">
<DialogHeader>
<DialogTitle>Creative Tim UI</DialogTitle>
</DialogHeader>
<DialogDescription className="mt-2 mb-6">
Creative Tim UI is an open-source library that uses the power of
Tailwind CSS and React to help you build unique web projects
faster and easier. The stunning design inspired by Material Design
is a bonus! Get Creative Tim UI and take advantage of its free
components and features that will help you set up your web project
quickly.
</DialogDescription>
<DialogFooter>
<Button variant="ghost" className="text-destructive">
Cancel
</Button>
<Button>Get Started</Button>
</DialogFooter>
</DialogContent>
</Dialog>
</div>
<div className="flex items-center justify-center gap-2">
<Dialog>
<DialogTrigger asChild>
<Button>Open LG</Button>
</DialogTrigger>
<DialogContent className="sm:max-w-2xl">
<DialogHeader>
<DialogTitle>Creative Tim UI</DialogTitle>
</DialogHeader>
<DialogDescription className="mt-2 mb-6">
Creative Tim UI is an open-source library that uses the power of
Tailwind CSS and React to help you build unique web projects
faster and easier. The stunning design inspired by Material Design
is a bonus! Get Creative Tim UI and take advantage of its free
components and features that will help you set up your web project
quickly.
</DialogDescription>
<DialogFooter>
<Button variant="ghost" className="text-destructive">
Cancel
</Button>
<Button>Get Started</Button>
</DialogFooter>
</DialogContent>
</Dialog>
<Dialog>
<DialogTrigger asChild>
<Button>Open XL</Button>
</DialogTrigger>
<DialogContent className="sm:max-w-4xl">
<DialogHeader>
<DialogTitle>Creative Tim UI</DialogTitle>
</DialogHeader>
<DialogDescription className="mt-2 mb-6">
Creative Tim UI is an open-source library that uses the power of
Tailwind CSS and React to help you build unique web projects
faster and easier. The stunning design inspired by Material Design
is a bonus! Get Creative Tim UI and take advantage of its free
components and features that will help you set up your web project
quickly.
</DialogDescription>
<DialogFooter>
<Button variant="ghost" className="text-destructive">
Cancel
</Button>
<Button>Get Started</Button>
</DialogFooter>
</DialogContent>
</Dialog>
<Dialog>
<DialogTrigger asChild>
<Button>Open Screen</Button>
</DialogTrigger>
<DialogContent className="sm:h-[95vh] sm:max-w-[95vw]">
<DialogHeader>
<DialogTitle>Creative Tim UI</DialogTitle>
</DialogHeader>
<DialogDescription className="mt-2 mb-6">
Creative Tim UI is an open-source library that uses the power of
Tailwind CSS and React to help you build unique web projects
faster and easier. The stunning design inspired by Material Design
is a bonus! Get Creative Tim UI and take advantage of its free
components and features that will help you set up your web project
quickly.
</DialogDescription>
<DialogFooter>
<Button variant="ghost" className="text-destructive">
Cancel
</Button>
<Button>Get Started</Button>
</DialogFooter>
</DialogContent>
</Dialog>
</div>
</div>
)
}
Dialog Web3
A Web3 wallet connection dialog displaying popular wallet options (MetaMask, Coinbase, Trust Wallet) with icons and a learn more link, perfect for cryptocurrency and blockchain applications.
import { Button } from "@/components/ui/button"
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog"
export function DialogWeb3() {
return (
<Dialog>
<DialogTrigger asChild>
<Button>Connect Wallet</Button>
</DialogTrigger>
<DialogContent className="pb-4 sm:max-w-md">
<DialogHeader>
<DialogTitle>Connect a Wallet</DialogTitle>
<DialogDescription>
Choose which card you want to connect
</DialogDescription>
</DialogHeader>
<div className="mt-4">
<h6 className="mb-2 font-semibold">Popular</h6>
<div className="space-y-2">
<Button
variant="secondary"
className="flex w-full items-center justify-center gap-2"
>
<img
alt="metamask"
src="https://docs.material-tailwind.com/icons/metamask.svg"
className="h-5 w-5"
/>
<span className="font-semibold">Connect with MetaMask</span>
</Button>
<Button
variant="secondary"
className="flex w-full items-center justify-center gap-2"
>
<img
alt="coinbase"
src="https://docs.material-tailwind.com/icons/coinbase.svg"
className="h-6 w-6 rounded"
/>
<span className="font-semibold">Connect with Coinbase</span>
</Button>
</div>
<h6 className="mt-6 mb-2 font-semibold">Other</h6>
<Button
variant="secondary"
className="flex w-full items-center justify-center gap-2"
>
<img
alt="trust-wallet"
src="https://docs.material-tailwind.com/icons/trust-wallet.svg"
className="h-6 w-6 rounded"
/>
<span className="font-semibold">Connect with Trust Wallet</span>
</Button>
</div>
<div className="mt-12 flex w-full items-center justify-between gap-2">
<p className="text-muted-foreground text-sm">
New to Ethereum wallets?
</p>
<Button variant="outline" size="sm">
Learn More
</Button>
</div>
</DialogContent>
</Dialog>
)
}
Dialog with Form
A dialog containing a complete sign-in form with email and password inputs, checkbox for remember me, and sign-up link, demonstrating how to integrate forms within dialogs.
import { Button } from "@/components/ui/button"
import { Checkbox } from "@/components/ui/checkbox"
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
export function DialogWithForm() {
return (
<Dialog>
<DialogTrigger asChild>
<Button>Sign In</Button>
</DialogTrigger>
<DialogContent className="sm:max-w-md">
<DialogHeader>
<DialogTitle>Sign In</DialogTitle>
<DialogDescription>
Enter your email and password to Sign In.
</DialogDescription>
</DialogHeader>
<form action="#" className="mt-6">
<div className="mt-2 mb-4 space-y-1.5">
<Label htmlFor="email" className="font-semibold">
Email
</Label>
<Input id="email" type="email" placeholder="[email protected]" />
</div>
<div className="mb-4 space-y-1.5">
<Label htmlFor="password" className="font-semibold">
Password
</Label>
<Input id="password" type="password" placeholder="************" />
</div>
<div className="mb-4 flex items-center gap-2">
<Checkbox id="checkbox" />
<Label
htmlFor="checkbox"
className="cursor-pointer text-sm font-normal"
>
Remember Me
</Label>
</div>
<Button type="submit" className="w-full">
Sign In
</Button>
</form>
<p className="text-muted-foreground mt-3 mb-2 flex items-center justify-center gap-1 text-sm">
Don't have an account?{" "}
<a href="#" className="text-primary font-semibold">
Sign up
</a>
</p>
</DialogContent>
</Dialog>
)
}
Dialog with Image
A full-featured image dialog with user profile information, image display, view/download statistics, and action buttons, perfect for image galleries or media viewing interfaces.
import { Heart, Share2 } from "lucide-react"
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"
import { Button } from "@/components/ui/button"
import { Dialog, DialogContent, DialogTrigger } from "@/components/ui/dialog"
export function DialogWithImage() {
return (
<Dialog>
<DialogTrigger asChild>
<button className="cursor-pointer outline-none">
<img
alt="nature"
src="https://images.unsplash.com/photo-1501854140801-50d01698950b?auto=format&w=2000&q=85"
className="h-64 w-auto rounded-lg object-cover object-center"
/>
</button>
</DialogTrigger>
<DialogContent className="sm:max-w-4xl">
<div className="flex items-center justify-between">
<div className="flex items-center gap-3">
<Avatar>
<AvatarImage
src="https://images.unsplash.com/photo-1574015974293-817f0ebebb74?auto=format&fit=crop&q=80&w=400&h=400"
alt="alex andrew"
/>
<AvatarFallback>AA</AvatarFallback>
</Avatar>
<div className="flex flex-col">
<span className="font-semibold">Alex Andrew</span>
<span className="text-muted-foreground text-sm">@alexandrew</span>
</div>
</div>
<div className="flex items-center gap-2">
<Button size="sm" variant="ghost" className="text-destructive">
<Heart className="h-4 w-4" />
</Button>
<Button size="sm">Free Download</Button>
</div>
</div>
<div className="my-4">
<img
alt="nature"
src="https://images.unsplash.com/photo-1501854140801-50d01698950b?auto=format&w=2000&q=85"
className="h-[48rem] w-full rounded-lg object-cover object-center"
/>
</div>
<div className="flex items-end justify-between">
<div className="flex items-center gap-16">
<div>
<p className="text-muted-foreground text-sm">Views</p>
<p className="font-semibold">44,082,044</p>
</div>
<div>
<p className="text-muted-foreground text-sm">Downloads</p>
<p className="font-semibold">553,031</p>
</div>
</div>
<Button size="sm" variant="ghost">
<Share2 className="mr-1.5 h-4 w-4" /> Share
</Button>
</div>
</DialogContent>
</Dialog>
)
}
Best Practices
- Use dialogs for important actions that require user attention
- Keep dialog content concise and focused
- Provide clear action buttons (Cancel/Confirm, etc.)
- Use appropriate dialog sizes based on content
- Ensure dialogs are accessible with proper ARIA labels
- Consider mobile responsiveness when sizing dialogs
- Use scrollable content for long dialogs
- Provide a way to close the dialog (close button or outside click)
- Use dialogs for forms, confirmations, and important notifications
- Consider using dialogs for image galleries or media viewing
Dialog components provide a flexible way to display modal content while maintaining focus on the current task. They're ideal for forms, confirmations, notifications, image viewing, and any interface where you need to temporarily overlay content on the page.