Prepared Docs

Prepared Docs

⌘K

    Loading navigation…

User

  1. Components
  2. Modal
  3. API and Development

Modal

API and Development

View Source
Submit Issue

Modal displays a dialog overlay that focuses user attention on specific content or actions, typically used for confirmations, forms, or important information. It provides a flexible dialog interface with header, content, and footer sections, supporting confirmations, cancellations, and various interaction patterns. Built with portal rendering and animation support, it ensures consistent modal patterns across the interface with full keyboard and screen reader accessibility.

Props

NameDefaultDescription
idrequiredUnique identifier for the modal. Used with ModalProvider to manage modal state.
headingrequiredThe heading text displayed at the top of the modal.
childrenrequiredThe content to display inside the modal body.
onConfirmrequiredCallback function called when the confirm button is clicked: () => void.
onConfirmText"Confirm"Text to display on the confirm button.
onCancelOptional callback function called when the cancel button is clicked: () => void.
onCancelText"Cancel"Text to display on the cancel button. Only shown when onCancel is provided.
noDismissfalseWhether the modal can be dismissed by clicking the backdrop or dismiss button.
shouldAllowDismissCalled before backdrop or header-X dismiss. Return false to keep the modal open.
confirmDisabledfalseWhether the confirm button should be disabled.
closeOnConfirmtrueWhether the modal should close automatically when the confirm button is clicked.
destructivefalseWhether the modal should use destructive styling for the confirm button.

Basic Modal

Use for simple confirmations or information dialogs.

Single Button Modal

Use when only confirmation is needed, without a cancel option.

Destructive Modal

Use for actions that have significant consequences or cannot be undone.

Modal with Custom Button Text

Customize button labels to match the action context.

Non-Dismissible Modal

Prevent users from closing the modal until they complete the action.

Modal with Disabled Confirm

Disable the confirm button until form validation or conditions are met.

Modal That Stays Open on Confirm

Keep the modal open after confirmation for multi-step processes or validation feedback.

Modal with Scrollable Content

Use Scrollable component for modals with long content.

Multiple Modals

Support multiple modals that can be stacked or opened simultaneously.

ModalProvider Setup

Wrap your application with ModalProvider and include ModalPortal to enable modal functionality.

useModal Hook

Use the useModal hook to control modal visibility (open, close, isOpen).

Previous

Modal / Usage

Next

Accessibility / Focus Management

On this page

Props
Basic Modal
Single Button Modal
Destructive Modal
Modal with Custom Button Text
Non-Dismissible Modal
Modal with Disabled Confirm
Modal That Stays Open on Confirm
Modal with Scrollable Content
Multiple Modals
ModalProvider Setup
useModal Hook