Modals are dialogs displayed over inert content that allow users to complete a singular, focused task without leaving the page.

Anatomy

  1. Overlay: The Modal's semi-transparent backdrop renders main page content inert and draws focus to the Modal itself.
  2. Header: The optional header contains Modal title.
  3. Close Button: An icon-only button that dismisses the Modal and renders by default but can be hidden.
  4. Body: The Modal body is scrollable by default if content extends past the container.
  5. Secondary Action: Secondary actions are housed within the optional footer.
  6. Primary Action: Primary actions are housed within the optional footer.

Guidelines

Modals are dialog boxes that display over the main page content that require the user's attention. Modals may hold supplemental information, request user interaction, or include a related workflow.

When to use

Be decisive when using Modals—versatility paves the road to misuse. Consider the following use cases before deciding to use a Modal:

  • Action confirmation. Performing destructive actions such as deleting data should require additional input from the user.
  • Additional tasks. Some required tasks may be too large to fit within the workflow or not large or contextually different enough to warrant its own page. Modals fit this use case.
  • Feature moments. Modals can be used to celebrate user actions and accomplishments such as starting a new campaign or exporting data. Use these sparingly.

Modals, Drawers, and Popovers are all dialogs that overlay page content to divert the user's attention. However, it's important to understand the difference as they are not interchangeable:

  • Modals are centered in the viewport and render page content inert. They're useful when users must confirm a task, such as short forms, agreements, and confirmations.
  • Drawers slide in from the edge of the viewport and may allow some interaction with the page content. Use them for content that has less contextual meaning to the main page such as updating settings or full-detail views without leaving the page.
  • Popovers anchor to their trigger element and appear inline without blocking a large portion of the page. They're more suited for smaller snippets of supplementary material or quickly dismissable interactions.

Best practices

Nesting

Never nest Modals. While doing so is possible, it's not a pattern we'd like to encourage due to poor user experience. Nested Modals complicate a workflow and increase the cognitive load a user may experience when attempting to complete a single, focused task.

Consider the following questions if nested Modals become a consideration:

  • Can the flow be reworked?
  • Can the content be written inline or on another page?
  • Can another component such as a Popover be used?
Don't: Nest modals to complete tasks.

Common patterns

Though Modals are highly customizable to fit a variety of use cases, it's best to reach for existing Modal patterns to maintain consistency throughout the system and application. Decide if your use case fits one of the following patterns before creating a new standard.

Confirmation

Confirmation Modals hide the default close button to prompt a user decision. Primary and secondary buttons are used within the footer.

Destructive confirmation

Destructive Modals require additional user input for irreversible actions. The default close button is hidden. The primary action is disabled until the input requirements are met.

Form

Form Modals include input fields to collect data. Dismissal by overlay click is disabled to prevent accidental data loss. The footer actions include the submit and cancel buttons.

Save/discard

Modals can be used to ask the user if they'd like to save or discard changes they've made, or cancel the process entirely.

Informational

Modals may display important read-only information, such as details or logs. The footer contains a single primary dismiss button.

Feature moment

Rarely, a Modal may be used to celebrate a completed action or introduce a new feature. Split Modals are used to present special graphics with the main content. A single call-to-action is included in the footer.

Types

Standard

Default Modals have a single column layout with an optional header and footer, and scrollable body content.

Split

Split Modals divide the modal into two equal columns. Place the split panel before or after the body to control which side it appears on.

Appearance

Close button

The close button is visible by default for an easily visible way to dismiss the Modal. If required, it may be hidden. Hiding the close button are more appropriate for Modals that require immediate user input for an important action, such as deleting data. For such use cases, be sure to include a "Cancel" button.

Close button

Modals include a close button by default.

No close button

Close buttons may be hidden for cases where user confirmation is required.

Inset

ModalInset renders content edge-to-edge within the modal, extending over the default padding. Use it for full-width backgrounds, images, or dividers that should bleed to the modal's edges.

Inset

Content extends to the modal's edges, ignoring the default padding.

Sizes

Medium

Medium Modals are the default for most use cases.

Small

Small Modals are more suitable for shorter content and smaller viewports.

Behaviors

Animation

Modals animate in and out with a fade and downward slide. The overlay fades in and out independently. The default animation duration is 125ms but can be customized.

Scrolling

By default, when Modal content exceeds the Modal container's max height, body content will scroll while the header and footer remain fixed. Scroll behavior can be changed so the entire Modal will scroll with the viewport instead.

Modal body scrolling

Body content scrolls within the modal.

Viewport scrolling

The entire Modal scrolls within the viewport.

Dismissal

Modals can be dismissed through multiple methods: close button, action button, overlay click, and the Escape key. The close button may be hidden and both the Escape key and overlay click may be disabled with props.

Use non-dismissable Modals for cases where user interaction is mandatory, such as confirming a destructive action.

Note: Non-dismissable Modal examples are dismissable with the Escape key. This is purely for display purposes.

Non-dismissable

Reserve non-dismissable modals for actions that require an explicit choice.

Content

When writing Modal content, keep the patterns below in mind:

Structure

table
ElementPatternExample
TitleAction + object name?Delete Q3 Re-engagement?
BodyConsequence. State if irreversible or recovery window.This campaign will be deleted. This cannot be undone.
ConfirmVerb + objectDelete campaign
CancelCancelCancel

Action labels

Footer action labels should describe what action will take place when activated. Mirror the title's verb when possible to reinforce the action.

Do: Use specific verbs that match the modal's purpose.
Don't: Use generic labels like OK or Submit when a specific verb is available.

Content length

While Modals are capable of expecting longer content than Popovers, we recommend keeping its content as concise as possible. The goal of a Modal is to help complete a single focused task. If more attention is required or multi-step tasks or workflows are intended, consider moving the content to a new page.

Do: Keep content as brief and focused as possible.

Titles

Titles should clearly describe the purpose of the modal in sentence case and include the object's name. When asking for confirmation, be sure the title ends in a question mark.

Do: Use a descriptive, action-oriented title.
Don't: Use vague or generic titles.