Overview
AxModal is a styled wrapper around Ant Design’s Modal component, providing preset sizes, danger mode for destructive actions, and consistent styling with the design system.Import
Basic Usage
Props
AxModal-specific Props
Short description rendered below the title in muted text. Provides additional context for the modal action.
Danger mode — makes the primary action button red. Use for destructive confirmations like delete, cancel order, or withdraw bid.
Preset sizes:
sm: 380px — compact size for simple confirmationsmd: 520px — standard size for forms and contentlg: 720px — wide size for tables, lists, and complex content
width prop for custom sizes.Common Modal Props
Whether the modal is visible.
The modal title. Combined with
description to form the header block.Custom width of the modal. Overrides the
size preset.Custom footer content. When
null, no footer is rendered. When undefined (default), renders OK/Cancel buttons using AxButton.Whether to center the modal vertically on the screen.
Whether the modal is in loading state. Shows a loading spinner in the modal.
Text for the OK button.
Text for the Cancel button.
Whether the OK button is in loading state. Use during async operations.
Props passed to the OK button. Note:
variant, type, danger, and ghost props are controlled by the modal and cannot be overridden.Props passed to the Cancel button. Note:
variant, type, danger, and ghost props are controlled by the modal and cannot be overridden.Callback when the OK button is clicked.
Callback when the Cancel button or close icon is clicked, or when clicking the mask.
Additional class name for the modal’s root element.
Whether to show the close icon in the top right corner.
Whether to show the mask (backdrop).
Whether clicking the mask closes the modal.
Whether the Escape key closes the modal.
Whether to unmount child components when the modal is closed.
Callback executed after the modal is fully closed (animation complete).
Callback when the open state changes, fired after animation completes.
The z-index of the modal.
Examples
Sizes
AxModal provides three preset sizes optimized for different use cases:Danger Mode
Use danger mode for destructive actions:Confirmation with Loading
Show loading state during async operations:Form Modal
Use for input collection:Success Modal
Provide feedback after an action:Custom Footer
Provide your own footer buttons:No Footer
Hide the footer entirely:Accessibility
- The modal automatically sets
aria-describedbywhen adescriptionis provided - Keyboard navigation is enabled by default (Escape to close)
- Focus is trapped within the modal when open
- The modal uses semantic HTML with proper ARIA attributes
Best Practices
- Use appropriate sizes:
smfor confirmations,mdfor forms,lgfor complex content - Enable danger mode for destructive actions (delete, cancel, withdraw)
- Provide descriptions to give users context about the action
- Use confirmLoading to show feedback during async operations
- Keep content focused — modals should have a single clear purpose
- Consider alternatives — for extensive forms or content, consider using a drawer instead