Dialogs

Modal

A world-class modal dialog component designed for healthcare applications. Features proper focus management, keyboard navigation, and full WCAG 2.1 accessibility compliance.

Basic Modal

Standard modal for displaying patient information or simple forms.

Form Modal

Modal containing a form for scheduling appointments. Uses larger size for complex forms.

Critical Modal (Prevent Close)

For critical workflows that require explicit action. Cannot be dismissed by clicking outside or pressing Escape.

Modal Sizes

Choose the appropriate size based on content complexity. Sizes range from compact (sm) to full-width (full).

Position Variants

Center position is default. Use top position for modals that may trigger additional dialogs.

Scrollable Content

Long content scrolls inside the modal body while header and footer remain fixed.

Props

PropTypeDefaultDescription
open *booleanControls modal visibility
id stringCustom ID (auto-generated if not provided)
title string'Dialog'Modal header title
size 'sm' | 'md' | 'lg' | 'xl' | '2xl' | 'full''md'Modal width
position 'center' | 'top''center'Vertical position
scrollBehavior 'inside' | 'outside''inside'Scroll behavior for long content
closeOnBackdrop booleantrueClose when clicking backdrop
closeOnEscape booleantrueClose on Escape key
showCloseButton booleantrueShow close button in header
preventClose booleanfalsePrevent closing (for critical modals)
initialFocus HTMLElement | nullElement to focus when modal opens
enableFocusTrap booleantrueEnable focus trap to keep focus within modal when open
header SnippetCustom header content (overrides title)
footer SnippetFooter slot for actions
children SnippetMain content
onclose *() => voidCalled when modal requests close
testId stringTest ID for e2e testing

Healthcare Best Practices

  • Use modals sparingly - they interrupt workflow and can cause user fatigue
  • For destructive actions (deleting records, cancelling appointments), use ConfirmDialog instead
  • Prevent accidental close for forms: use closeOnBackdrop={false}
  • Critical workflows: use preventClose={true} for drug interactions, safety alerts
  • Focus management is automatic - first focusable element receives focus on open
  • Focus trap keeps keyboard focus within the modal; disable with enableFocusTrap={false} if the modal contains elements that need external focus (e.g., date pickers with portaled calendars)
  • Escape key closes the modal by default (disable with closeOnEscape={false})
  • Screen readers: title is announced via aria-labelledby, content via aria-describedby
  • Focus restoration: when modal closes, focus returns to the element that opened it