Unkey
ComponentsDialogs

DialogContainer

Features

  • Accessible modal implementation
  • Customizable overlay and content styling
  • Close button with warning support
  • Keyboard navigation support
  • Customizable animations
  • Responsive design

Structure

The DialogContainer is composed of three main parts:

  1. Header - Contains the title and optional subtitle
  2. Content Area - The main content section where children are rendered
  3. Footer - Optional section for actions like buttons or additional information

Styling

The component comes with default styling that includes:

  • Responsive width and height constraints
  • Drop shadow and rounded corners
  • Overlay with backdrop blur
  • Dark mode support
  • Customizable through className and contentClassName props

Usage

<DialogContainer
  isOpen={isOpen}
  onOpenChange={setIsOpen}
  title="Example Dialog"
  subTitle="Optional subtitle text"
  footer={
    <Button onClick={handleAction}>
      Confirm
    </Button>
  }
>
  <div>Your dialog content here</div>
</DialogContainer>

Basic Example

Input Result:

Props

PropTypeDefaultDescription
isOpenboolean-Controls the open state of the dialog
onOpenChange(value: boolean) => void-Callback when the open state changes
titlestring-The title of the dialog
subTitlestring-Optional subtitle for the dialog
footerReactNode-Optional footer content
classNamestring-Additional classes for the dialog container
contentClassNamestring-Additional classes for the dialog content
preventAutoFocusbooleantrueWhether to prevent auto-focus on open
childrenReactNode-The content to display in the dialog

Accessibility

The DialogContainer implements the following accessibility features:

  • Manages focus trap within the dialog
  • Supports keyboard navigation (Esc to close)
  • Proper ARIA attributes for screen readers
  • Focus management can be controlled via preventAutoFocus

On this page