Skip to content

Modal

A dialog component for focused user interactions, confirmations, and forms.

Import

tsx
import { ZModal } from '@zurto/ui'

Basic Usage

ZButtonZModal

Welcome

This is a basic modal dialog.

Confirmation Dialog

ZModalZModalFooterZButton

Delete Item

Are you sure you want to delete this item? This action cannot be undone.

With Form

ZModalZInputZModalFooterZButton

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

PropTypeDefaultDescription
openRequiredbooleanfalseControls modal visibility
onCloseRequired() => voidCalled when modal should close
titlestringModal header title
size'sm' | 'md' | 'lg' | 'xl' | 'full''md'Modal width
closeOnOverlaybooleantrueClose when clicking backdrop
closeOnEscapebooleantrueClose when pressing Escape
showCloseButtonbooleantrueShow X button in header
scrollBehavior'inside' | 'outside''inside'How content scrolls
childrenRequiredReactNodeModal content

Compound Components

ComponentDescription
ZModalMain modal container
ZModalHeaderHeader with title and close button
ZModalBodyScrollable content area
ZModalFooterFooter with action buttons

Accessibility

  • Focus trapped inside modal when open
  • Focus restored to trigger element on close
  • role="dialog" with aria-modal="true"
  • aria-labelledby linked to title
  • Escape key closes modal (configurable)
  • Body scroll locked when open

Keyboard Support

KeyAction
EscapeClose modal (if enabled)
TabMove focus within modal
Shift + TabMove focus backwards

Released under the MIT License.