NOCTA UI

Dialog

A modal dialog component for displaying content over the main interface with backdrop, keyboard navigation and accessibility features

Installation

Install the Dialog component using the nocta-ui CLI:

npx nocta-ui add dialog

Import the components you need:

import {
  Dialog,
  DialogTrigger,
  DialogContent,
  DialogHeader,
  DialogTitle,
  DialogDescription,
  DialogFooter,
  DialogActions,
  DialogClose,
} from '@/components/ui/dialog';

Examples

Simple Dialog

Dialog with Actions

Sizes

The Dialog component supports different sizes: sm, md, lg, and xl. The default size is md.

API Reference

Dialog

The root component that manages dialog state.

PropTypeDefaultDescription
openbooleanundefinedControls the dialog state
onOpenChange(open: boolean) => voidundefinedCallback when dialog state changes
childrenReact.ReactNode-Dialog content

DialogTrigger

Button that opens the dialog.

PropTypeDefaultDescription
asChildbooleanfalseRender as child element instead of button
classNamestring''Additional CSS classes to apply
childrenReact.ReactNode-Trigger content

DialogContent

The dialog modal content.

PropTypeDefaultDescription
size'sm' | 'md' | 'lg' | 'xl' | 'md'`Dialog size
showClosebooleantrueShow close button
portalbooleantrueRender the dialog in a React portal
classNamestring''Additional CSS classes to apply
childrenReact.ReactNode-Dialog content

DialogClose

Button that closes the dialog.

PropTypeDefaultDescription
asChildbooleanfalseRender as child element instead of button
classNamestring''Additional CSS classes to apply
childrenReact.ReactNode-Close button content

DialogHeader

Container for the title and description.

PropTypeDefaultDescription
classNamestring''Additional CSS classes to apply
childrenReact.ReactNode-Header content

DialogTitle

Accessible heading for the dialog.

PropTypeDefaultDescription
asReact.ElementType'h2'Optional element type for the heading
classNamestring''Additional CSS classes to apply
childrenReact.ReactNode-Title content

DialogDescription

Accessible description for the dialog.

PropTypeDefaultDescription
classNamestring''Additional CSS classes to apply
childrenReact.ReactNode-Description content

DialogFooter

Footer container, typically for actions.

PropTypeDefaultDescription
classNamestring''Additional CSS classes to apply
childrenReact.ReactNode-Footer content

DialogActions

Layout container for action buttons.

PropTypeDefaultDescription
classNamestring''Additional CSS classes to apply
childrenReact.ReactNode-Actions content