--- title: Dialog description: A popup that opens on top of the entire page. links: doc: https://base-ui.com/react/components/dialog#api-reference --- ## Installation CLI Manual ```bash npx shadcn@latest add @coss/dialog ``` Install the following dependencies: ```bash npm install @base-ui/react ``` Copy and paste the following code into your project. Update the import paths to match your project setup. ## Usage ```tsx import { Dialog, DialogClose, DialogDescription, DialogPanel, DialogFooter, DialogHeader, DialogPopup, DialogTitle, DialogTrigger, } from "@/components/ui/dialog" ``` ```tsx Open Dialog Dialog Title Dialog Description Content Close ``` ## API Reference ### Dialog Root component. Alias for `Dialog.Root` from Base UI. ### DialogTrigger Trigger button that opens the dialog. Alias for `Dialog.Trigger` from Base UI. ### DialogCreateHandle Creates a handle for detached dialog triggers. Use it when the trigger and popup need to be coordinated across different parts of the tree. ### DialogPopup Popup container that displays the dialog content. Also exported as `DialogContent`. | Prop | Type | Default | Description | | --------------------- | --------------------------- | ------- | ------------------------------------------------ | | `showCloseButton` | `boolean` | `true` | When true, displays a close button in the top-right corner | | `bottomStickOnMobile` | `boolean` | `true` | When true, sticks to the bottom of the screen on mobile devices | | `closeProps` | `Dialog.Close.Props` | - | Props forwarded to the internal close button, useful for overriding `aria-label` | | `portalProps` | `Dialog.Portal.Props` | - | Props forwarded to the internal portal (`keepMounted`, `container`, etc.); see Base UI Dialog portal API | ### DialogHeader Container for the dialog title and description. Supports the `render` prop for polymorphic composition (e.g. `render={}`). ### DialogFooter Footer section for action buttons. Supports the `render` prop for polymorphic composition. | Prop | Type | Default | Description | | ----------- | ------------------------ | ----------- | ------------------------------------------------ | | `variant` | `"default" \| "bare"` | `"default"` | Controls the footer styling. `default` includes border and background, `bare` removes them | **Example:** ```tsx // Default variant (with border and background) Cancel // Bare variant (no border or background) Cancel ``` ### DialogTitle Title component. Alias for `Dialog.Title` from Base UI. ### DialogDescription Description component. Alias for `Dialog.Description` from Base UI. ### DialogPanel Scrollable content container. Automatically wraps content in a `ScrollArea` component. Supports the `render` prop for polymorphic composition. | Prop | Type | Default | Description | | ------------ | --------- | ------- | ------------------------------------------------ | | `scrollFade` | `boolean` | `true` | When true, shows a fade effect at scroll edges | **Example:** ```tsx {/* Long content that will scroll if it exceeds the dialog height */}
...
``` ### DialogClose Close button component. Alias for `Dialog.Close` from Base UI. ### DialogPortal Portal component for rendering outside the DOM hierarchy. Alias for `Dialog.Portal` from Base UI. ### DialogBackdrop Backdrop/overlay component. Also exported as `DialogOverlay`. Alias for `Dialog.Backdrop` from Base UI. ### DialogViewport Viewport component for positioning. Alias for `Dialog.Viewport` from Base UI. ## Examples ### Open from a Menu ### Dialog with Bare Footer ### Dialog with scroll inside ### Nested Dialogs ### Close Confirmation