dialog
shadcn/dialogFreeComponent
shadcn publishes no description for this item.
Live preview
live · rendered by the registry
Rendered by shadcn on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add dialogSource
1"use client"23import * as React from "react"4import * as DialogPrimitive from "@radix-ui/react-dialog"5import { X } from "lucide-react"67import { cn } from "@/lib/utils"89const Dialog = DialogPrimitive.Root1011const DialogTrigger = DialogPrimitive.Trigger1213const DialogPortal = DialogPrimitive.Portal1415const DialogClose = DialogPrimitive.Close1617const DialogOverlay = React.forwardRef<18 React.ElementRef<typeof DialogPrimitive.Overlay>,19 React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>20>(({ className, ...props }, ref) => (21 <DialogPrimitive.Overlay22 ref={ref}23 className={cn(24 "fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",25 className26 )}27 {...props}28 />29))30DialogOverlay.displayName = DialogPrimitive.Overlay.displayName3132const DialogContent = React.forwardRef<33 React.ElementRef<typeof DialogPrimitive.Content>,34 React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>35>(({ className, children, ...props }, ref) => (36 <DialogPortal>37 <DialogOverlay />38 <DialogPrimitive.Content39 ref={ref}40 className={cn(41 "fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",42 className43 )}44 {...props}45 >46 {children}47 <DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">48 <X className="h-4 w-4" />49 <span className="sr-only">Close</span>50 </DialogPrimitive.Close>51 </DialogPrimitive.Content>52 </DialogPortal>53))54DialogContent.displayName = DialogPrimitive.Content.displayName5556const DialogHeader = ({57 className,58 ...props59}: React.HTMLAttributes<HTMLDivElement>) => (60 <div61 className={cn(62 "flex flex-col space-y-1.5 text-center sm:text-left",63// … truncated
What it pulls in
Other registry items
Files it writes
More from shadcn
All 62 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| accordionaccordion | shadcn | Components | Free | no deps | |
| alertalert | shadcn | Components | Free | no deps | |
| alert-dialogalert-dialog | shadcn | Components | Free | no deps | |
| aspect-ratioaspect-ratio | shadcn | Components | Free | no deps | |
| attachmentattachment | shadcn | Components | Free | no deps | |
| avataravatar | shadcn | Components | Free | no deps | |
| badgebadge | shadcn | Components | Free | no deps | |
| breadcrumbbreadcrumb | shadcn | Components | Free | no deps |
