Component

Dialog

A modal dialog with Neo-Brutalism styling. Built on Radix UI Dialog primitive with full accessibility support.

Preview

Installation

pnpm dlx brutx@latest add dialog

Usage

import {
  Dialog,
  DialogTrigger,
  DialogContent,
  DialogHeader,
  DialogTitle,
  DialogDescription,
  DialogFooter,
  DialogClose,
  DialogPortal,
  DialogOverlay,
} from "@/components/ui/dialog"
import { Button } from "@/components/ui/button"

<Dialog>
  <DialogTrigger asChild>
    <Button>Open Dialog</Button>
  </DialogTrigger>
  <DialogContent>
    <DialogHeader>
      <DialogTitle>Dialog Title</DialogTitle>
      <DialogDescription>
        Dialog description text.
      </DialogDescription>
    </DialogHeader>
    <div>
      {/* Content */}
    </div>
    <DialogFooter>
      <Button variant="outline">Cancel</Button>
      <Button variant="primary">Confirm</Button>
    </DialogFooter>
  </DialogContent>
</Dialog>

Examples

Form Dialog

Dialog with form inputs for editing data.

Without Close Button

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

Controlled Dialog

Control the dialog state programmatically with open and onOpenChange.

Custom Close Button

Use DialogClose to create custom close buttons anywhere in the dialog.

API Reference

Dialog

The root component that manages dialog state.

PropTypeDefaultDescription
openboolean-Controlled open state of the dialog
onOpenChange(open: boolean) => void-Callback when open state changes
defaultOpenbooleanfalseInitial open state (uncontrolled)
modalbooleantrueWhether to block interaction outside the dialog

DialogContent

The container for dialog content with animations and overlay.

PropTypeDefaultDescription
showCloseButtonbooleantrueShow the default close button in top-right corner
classNamestring-Additional CSS classes for the content container
onEscapeKeyDown(event) => void-Handler called when Escape key is pressed

All Exports

ComponentDescription
DialogRoot component managing state
DialogTriggerButton that opens the dialog
DialogContentMain content container with overlay
DialogHeaderHeader section with bottom border
DialogFooterFooter section with top border
DialogTitleAccessible title element
DialogDescriptionAccessible description element
DialogClosePrimitive for custom close buttons
DialogPortalPortals content to document body
DialogOverlayBackground overlay component

Accessibility

  • Focus is trapped within the dialog when open
  • Escape key closes the dialog
  • Clicking outside closes the dialog (when modal)
  • Screen reader announcements for dialog content
  • Returns focus to trigger element on close
  • Uses role="dialog" and aria-modal