Dialog
cubby-ui/dialogFreeComponent
A dialog component.
Live preview
live · rendered by the registry
Rendered by cubby-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://cubby-ui.dev/r/dialog.jsonSource
1"use client";23import * as React from "react";4import { Dialog as BaseDialog } from "@base-ui/react/dialog";5import { cn } from "@/lib/utils";6import { Button } from "@/registry/default/button/button";7import {8 elevatedSurface,9 type SurfaceLevel,10} from "@/registry/default/lib/elevated";11import {12 ScrollArea,13 type ScrollAreaProps,14} from "@/registry/default/scroll-area/scroll-area";1516import { HugeiconsIcon } from "@hugeicons/react";17import { Cancel01Icon } from "@hugeicons/core-free-icons";18interface DialogConfigContextValue {19 modal: boolean | "trap-focus";20}2122const DialogConfigContext = React.createContext<DialogConfigContextValue>({23 modal: true,24});2526function Dialog<Payload>({27 modal = true,28 disablePointerDismissal,29 ...props30}: BaseDialog.Root.Props<Payload>) {31 const configValue = React.useMemo(() => ({ modal }), [modal]);32 return (33 <DialogConfigContext.Provider value={configValue}>34 <BaseDialog.Root35 modal={modal}36 disablePointerDismissal={disablePointerDismissal ?? modal !== true}37 {...props}38 />39 </DialogConfigContext.Provider>40 );41}4243const createDialogHandle = BaseDialog.createHandle;4445function DialogPortal({ ...props }: BaseDialog.Portal.Props) {46 return <BaseDialog.Portal data-slot="dialog-portal" {...props} />;47}4849function DialogTrigger({ ...props }: BaseDialog.Trigger.Props) {50 return <BaseDialog.Trigger data-slot="dialog-trigger" {...props} />;51}5253function DialogClose({ ...props }: BaseDialog.Close.Props) {54 return <BaseDialog.Close data-slot="dialog-close" {...props} />;55}5657function DialogBackdrop({ className, ...props }: BaseDialog.Backdrop.Props) {58 return (59 <BaseDialog.Backdrop60 className={cn(61 "ease-out-expo fixed inset-0 min-h-dvh bg-black/40 transition-all duration-200 supports-[-webkit-touch-callout:none]:absolute",62 "backdrop-blur-sm data-ending-style:opacity-0 data-starting-style:opacity-0",63 className,64 )}65 {...props}66 />67 );68}6970function DialogViewport({ className, ...props }: BaseDialog.Viewport.Props) {71 return (72 <BaseDialog.Viewport73 data-slot="dialog-viewport"74 className={cn(75 "fixed inset-0 flex flex-col items-center justify-center overflow-hidden px-4 py-6",76 className,77 )}78 {...props}79 />80 );81}8283function DialogContent({84 className,85 children,86 showCloseButton = true,87 variant = "default",88 level = 5,89 shadowLevel = 5,90 ...props91}: BaseDialog.Popup.Props & {92// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from cubby-ui
All 79 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | cubby-ui | Components | Free | 2 deps | |
| Alertalert | cubby-ui | Components | Free | 1 dep | |
| Alert-dialogalert-dialog | cubby-ui | Components | Free | 2 deps | |
| Aspect-ratioaspect-ratio | cubby-ui | Components | Free | no deps | |
| Autocompleteautocomplete | cubby-ui | Components | Free | 2 deps | |
| Avataravatar | cubby-ui | Components | Free | 1 dep | |
| Badgebadge | cubby-ui | Components | Free | 1 dep | |
| Base Drawerbase-drawer | cubby-ui | Components | Free | 2 deps |
