'use client' import * as React from 'react' import { Button } from '@/components/ui/button' import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, } from '@/components/ui/dialog' import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from '@/components/ui/card' import { Input } from '@/components/ui/input' import { Label } from '@/components/ui/label' import { toast } from 'sonner' export default function DialogsPage() { const [isOpen, setIsOpen] = React.useState(false) const handleSave = () => { toast.success('Changes saved successfully!') setIsOpen(false) } return (

Dialog Examples

Modal dialogs with focus trapping and keyboard navigation

{/* Basic Dialog */} Basic Dialog Simple dialog with title and content Welcome! This is a basic dialog example. Press ESC or click outside to close.

Dialogs automatically handle:

  • Focus trapping
  • Keyboard navigation (ESC to close)
  • Backdrop click to dismiss
  • Return focus on close
{/* Dialog with Form */} Dialog with Form Dialog containing a form with inputs Edit Profile Make changes to your profile here. Click save when you're done.
{/* Confirmation Dialog */} Confirmation Dialog Destructive action confirmation Are you absolutely sure? This action cannot be undone. This will permanently delete your item and remove your data from our servers. {/* Info Dialog */} Information Dialog Display information without actions About This App Built with modern web technologies

Stack

  • • Next.js 16 with App Router
  • • React 19
  • • Tailwind CSS v3/v4
  • • shadcn/ui components
  • • TypeScript

Features

  • • Dark mode support
  • • Fully accessible (WCAG 2.1 AA)
  • • Type-safe
  • • Production-ready
{/* Accessibility Info */} Dialog Accessibility shadcn/ui dialogs are built on Radix UI with full accessibility

Keyboard Navigation

  • ESC - Close dialog
  • Tab - Move focus forward
  • Shift + Tab {' '} - Move focus backward

Screen Reader Support

  • Dialog title is announced via{' '} aria-labelledby
  • Description is read via{' '} aria-describedby
  • Focus is trapped within dialog when open
  • Focus returns to trigger element on close

Mouse/Touch Support

  • Click backdrop to dismiss (optional)
  • Close button in top-right corner
  • Scroll content if overflowing
) }