Back to Shadcn Ui

Dialog

apps/v4/content/docs/components/radix/dialog.mdx

latest2.2 KB
Original Source

<ComponentPreview styleName="radix-nova" name="dialog-demo" description="A dialog for editing profile details." />

Installation

<CodeTabs> <TabsList> <TabsTrigger value="cli">Command</TabsTrigger> <TabsTrigger value="manual">Manual</TabsTrigger> </TabsList> <TabsContent value="cli">
bash
npx shadcn@latest add dialog
</TabsContent> <TabsContent value="manual"> <Steps className="mb-0 pt-2">

<Step>Install the following dependencies:</Step>

bash
npm install radix-ui

<Step>Copy and paste the following code into your project.</Step>

<ComponentSource name="dialog" title="components/ui/dialog.tsx" styleName="radix-nova" />

<Step>Update the import paths to match your project setup.</Step>

</Steps> </TabsContent> </CodeTabs>

Usage

tsx
import {
  Dialog,
  DialogContent,
  DialogDescription,
  DialogHeader,
  DialogTitle,
  DialogTrigger,
} from "@/components/ui/dialog"
tsx
<Dialog>
  <DialogTrigger>Open</DialogTrigger>
  <DialogContent>
    <DialogHeader>
      <DialogTitle>Are you absolutely sure?</DialogTitle>
      <DialogDescription>
        This action cannot be undone. This will permanently delete your account
        and remove your data from our servers.
      </DialogDescription>
    </DialogHeader>
  </DialogContent>
</Dialog>

Examples

Custom Close Button

Replace the default close control with your own button.

<ComponentPreview styleName="radix-nova" name="dialog-close-button" />

No Close Button

Use showCloseButton={false} to hide the close button.

<ComponentPreview styleName="radix-nova" name="dialog-no-close-button" />

Keep actions visible while the content scrolls.

<ComponentPreview styleName="radix-nova" name="dialog-sticky-footer" />

Scrollable Content

Long content can scroll while the header stays in view.

<ComponentPreview styleName="radix-nova" name="dialog-scrollable-content" />

RTL

To enable RTL support in shadcn/ui, see the RTL configuration guide.

<ComponentPreview styleName="radix-nova" name="dialog-rtl" direction="rtl" />

API Reference

See the Radix UI documentation for more information.