Componentfeedback1.74 KB gzipZero dependencies
Dialog
Accessible modal dialog with focus trap and scale animation.
Preview
Live Preview
Installation
Tokens guide →Add to your project via CLI (zero dependencies, code you own):
npx bigbullui add dialogOr install the full npm package:
npm install bigbulluiUsage
tsx12 lines
const [open, setOpen] = useState(false); <Button onClick={() => setOpen(true)}>Open</Button><Dialog open={open} onOpenChange={setOpen}> <DialogHeader> <DialogTitle>Title</DialogTitle> <DialogDescription>Description.</DialogDescription> </DialogHeader> <DialogFooter> <Button onClick={() => setOpen(false)}>Got it</Button> </DialogFooter></Dialog>Source code
dialog.tsx + 4 helpersZero third-party dependencies (5 local files shown in tabs below).
tsxdialog.tsx219 lines
"use client"; import * as React from "react";import { createPortal } from "react-dom";import { cn } from "./lib/utils";import { getFocusable, hideBackgroundSiblings, lockBodyScroll, registerEscapeLayer, trapFocus,} from "./lib/focus-trap";import { useIsMounted } from "./lib/react-compat";import { useControllableState } from "./lib/use-controllable-state"; interface DialogContextValue { titleId: string; descriptionId: string;Props
Interactive Prop Playground
Tweak parsed AST props below to generate ready-to-paste JSX.
tsx3 lines
import { Dialog } from "@/components/ui/dialog"; <Dialog />| Prop | Type | Description |
|---|---|---|
| open | boolean | Whether the dialog is open (controlled). |
| defaultOpen | boolean | Initial open state when uncontrolled. (Default: false) |
| onOpenChange | (open: boolean) => void | Called when open state should change. |
| children | React.ReactNode | Child elements rendered inside the component. |
| className | string | Optional Tailwind or custom CSS classes merged with component styles. |
| aria-label | string | Configures aria label. |
| hideCloseButton | boolean | Toggles hide close button. (Default: false) |
| animated | boolean | Dual-mode: false renders instantly with no motion. Default true. |
Pairs well with
Alert DialogConfirm/cancel modal with destructive variant for irreversible actions, Escape/backdrop close, and animated content.ConfirmDialogSelf-contained confirm dialog with focus trap and stamp entrance for confirm button in destructive mode.SheetSlide-over drawer panel with focus trap and scroll lock.DrawerBottom slide-up drawer with pull handle, backdrop blur, and focus trap.