Modal
A dialog component for focused user interactions, confirmations, and forms.
Import
tsx
import { ZModal } from '@zurto/ui'Basic Usage
Welcome
This is a basic modal dialog.
Confirmation Dialog
Delete Item
Are you sure you want to delete this item? This action cannot be undone.
With Form
Create Account
Sizes
tsx
<ZModal size="sm">Small modal (400px)</ZModal>
<ZModal size="md">Medium modal (500px)</ZModal>
<ZModal size="lg">Large modal (700px)</ZModal>
<ZModal size="xl">Extra large modal (900px)</ZModal>
<ZModal size="full">Full screen modal</ZModal>Close Options
tsx
// Close on overlay click (default: true)
<ZModal closeOnOverlay={false}>...</ZModal>
// Close on Escape key (default: true)
<ZModal closeOnEscape={false}>...</ZModal>
// Show close button (default: true)
<ZModal showCloseButton={false}>...</ZModal>Props
| Prop | Type | Default | Description |
|---|---|---|---|
openRequired | boolean | false | Controls modal visibility |
onCloseRequired | () => void | – | Called when modal should close |
title | string | – | Modal header title |
size | 'sm' | 'md' | 'lg' | 'xl' | 'full' | 'md' | Modal width |
closeOnOverlay | boolean | true | Close when clicking backdrop |
closeOnEscape | boolean | true | Close when pressing Escape |
showCloseButton | boolean | true | Show X button in header |
scrollBehavior | 'inside' | 'outside' | 'inside' | How content scrolls |
childrenRequired | ReactNode | – | Modal content |
Compound Components
| Component | Description |
|---|---|
ZModal | Main modal container |
ZModalHeader | Header with title and close button |
ZModalBody | Scrollable content area |
ZModalFooter | Footer with action buttons |
Accessibility
- Focus trapped inside modal when open
- Focus restored to trigger element on close
role="dialog"witharia-modal="true"aria-labelledbylinked to title- Escape key closes modal (configurable)
- Body scroll locked when open
Keyboard Support
| Key | Action |
|---|---|
Escape | Close modal (if enabled) |
Tab | Move focus within modal |
Shift + Tab | Move focus backwards |