Components · Feedback · Modal
Back to Modal typesModal
Use for a dialog box that appears above a dimmed backdrop to focus the user on one task or decision before returning them to the page - one Modal component, controlled by properties, not a one-off overlay built from scratch each time.
Properties
Size, corner radius, title, body text, icon and action labels are properties of the same component, not separate dialogs glued together - change them below to check this modal's style and scenarios in the Live Preview. No footer, Scrollable and No close aren't separate properties here since they're not mutually exclusive states - pick any row by name from the Live Preview's own State selector to see that combination (e.g. Scrollable + No close together).
Live Preview
All 2 types compared side by side, each across 7 representative scenarios - Default, No footer, Scrollable, No close, Scrollable + No close (proving they combine), Loading, and Error - at the chosen Size, title and body text. One full matrix is rendered per selected Corner radius.
Confirm-type shortcuts
Ant's Modal.info/.success/.warning/.error/.confirm - a pre-built icon-plus-title-plus-single-button shape for the moment a caller just needs to say one thing and move on, without re-declaring the header/footer boilerplate every time. Only Modal.confirm gets a Cancel button; the other four are acknowledge-only.
When to use
Any moment that needs to block the rest of the page until the user makes a decision or finishes a short, focused task.
Component Guide
Overview
Modal is a dialog box that appears above a dimmed backdrop to focus the user on one task or decision before returning them to the page - it blocks interaction with everything behind it until the user responds or explicitly closes it.
When to Use
- A destructive-action confirmation - confirming a delete before it happens.
- A short, focused task or form - terms acceptance, an onboarding step.
- A media preview that needs full attention - viewing an image or document in detail.
When Not to Use
- A task that needs more room than a dialog comfortably allows - use Drawer, which slides in from an edge instead of interrupting the whole page.
- A brief, non-blocking confirmation - use Toast or Alert - Modal's backdrop is a heavy interruption for something minor.
- Frequent or repeated interruptions in a single flow - excessive modal use breaks flow; consider inline validation or a Drawer instead.
Best Practices
- Give it a single clear purpose and a single primary action - avoid turning it into a small multi-purpose page.
- Always provide an obvious way to close it (a visible close button and Escape), even when a primary action is required.
- Keep destructive confirmations short and specific about the consequence, not a generic "Are you sure?"
Do and Don't
Do
This cannot be undone.
One decision, stated with its consequence, and a button that names the action rather than agreeing vaguely.
Don't
Please confirm.
"Are you sure?" with Yes/No never says what is about to happen, so the user confirms without knowing what they agreed to.
Accessibility
- Traps keyboard focus within the dialog while open, and restores it to the triggering element on close.
- Exposed as role="dialog" with aria-modal="true" and an accessible name (its title via aria-labelledby), announced as soon as it opens - this is about focus management and interruption, not aria-live, since a Modal blocks and demands a response rather than passively announcing a status.
- Escape always closes it, no matter the type or state. A visible close "x" is also available for Default and Destructive, unless explicitly hidden via the Show close property or the No-close state.
Related Components
Drawer, Pop Confirm, Result.
{
"component": "Modal",
"category": "Feedback",
"summary": "Modal is a dialog box that appears above a dimmed backdrop to focus the user on one task or decision before returning them to the page - it blocks interaction with everything behind it until the user responds or explicitly closes it.",
"whenToUse": [
"A destructive-action confirmation - confirming a delete before it happens.",
"A short, focused task or form - terms acceptance, an onboarding step.",
"A media preview that needs full attention - viewing an image or document in detail."
],
"whenNotToUse": [
"A task that needs more room than a dialog comfortably allows - use Drawer, which slides in from an edge instead of interrupting the whole page.",
"A brief, non-blocking confirmation - use Toast or Alert - Modal's backdrop is a heavy interruption for something minor.",
"Frequent or repeated interruptions in a single flow - excessive modal use breaks flow; consider inline validation or a Drawer instead."
],
"bestPractices": [
"Give it a single clear purpose and a single primary action - avoid turning it into a small multi-purpose page.",
"Always provide an obvious way to close it (a visible close button and Escape), even when a primary action is required.",
"Keep destructive confirmations short and specific about the consequence, not a generic \"Are you sure?\""
],
"doAndDont": {
"do": "One decision, stated with its consequence, and a button that names the action rather than agreeing vaguely.",
"dont": "\"Are you sure?\" with Yes/No never says what is about to happen, so the user confirms without knowing what they agreed to."
},
"accessibility": [
"Traps keyboard focus within the dialog while open, and restores it to the triggering element on close.",
"Exposed as role=\"dialog\" with aria-modal=\"true\" and an accessible name (its title via aria-labelledby), announced as soon as it opens - this is about focus management and interruption, not aria-live, since a Modal blocks and demands a response rather than passively announcing a status.",
"Escape always closes it regardless of type or state. A visible close \"x\" is also available for Default and Destructive unless explicitly hidden."
],
"relatedComponents": [
"Drawer",
"Pop Confirm",
"Result"
]
}