Skip to main content

Modal

Modals focus a user's attention on one task via a window that sits on top of the page. They present critical information, which may or may not require user input, before continuing the workflow.

By design, modals interrupt a user's workflow. Modals disable the main content area and prevent users from returning to their previous workflow until they complete the modal task or dismiss the modal.

Modals are mostly used for noting errors (original purpose) but they can be used for alerts, confirmations and custom requirements.

Anatomy

modal Formatting

Modals have a header, body and a footer.

  1. Header: The header contains the title of the modal window and communicates its purpose.
  2. Body: Contains supportive text that is necessary for users to complete the modal's task. Modals can also accommodate other components within the body.
  3. Buttons: The main actions that the user needs to complete or cancel the modal's task.
  4. Close icon: Closes the dialog without submitting any data.
  5. Overlay: Covers the main page content and renders it inactive until the modal's task is completed or dismissed.

Best practices

  • Use modals for important warnings and to prevent or correct critical errors.
  • Use modals for critical information that requires user input before continuing the workflow.
  • Use to partition a complex workflow into simpler steps.
  • Use to ask for input that, when entered, could significantly lessen the user's work or effort.
  • Use modals for essential information, related only to the current workflow.
  • Use modals for actions that require final confirmation before committing to it.
  • Be careful to not use a modal which will end up interrupting high-stakes processes such as a checkout flow.
  • Ensure the modal has all the needed information for a single decision.
    • Do not use modals for complicated decisions which requires additional information than what is available on the modal.
  • Customized modals should inherit the simplicity of regular models, with clear instructions and actions for the user.
  • The overlay should cover the entire page to bring attention to the modal.
  • When the modal is closed, the user is returned to the on-page content and their previous workflow.

Interactions

When a modal is triggered, certain elements such as buttons have an active, focus and hover state.

  • Focus: Provides feedback indicating element is highlighted using a keyboard or mouse.
  • Active: Provides feedback indicating the user is clicking or tapping the element.
  • Hover: Provides feedback indicating the user has placed a cursor over the element. (desktop only).

Clicking the close icon in the upper right will close the modal without submitting user data.

Clicking the primary action button completes the task and closes the modal.

The secondary action offers a way for the user to back out and take no action. Clicking the secondary button closes the modal and returns the user to their previous context.

Errors

  • Error messages should follow error messaging guidelines.

UX writing considerations

  • Headers should ask a single, clear question or communicate a single concise message. If the modal is informational or educational with no decision required, then the title can be a statement.
  • Avoid using "Are you sure" as a modal title. It's vague and users might not know what you're really asking. Instead, ask users the question you want them to answer using the specific action, e.g., Send payment?

Body

  • Body text should clarify any consequences and explain options in simple terms.
  • Avoid including information that is unrelated to the decision or complicated descriptions of rare situations.
  • For informational modals, use the correct tone to match the nature of the message. For example, when seeking to prevent an error, UX text should be clear and straightforward.

Buttons

  • Primary button text should state an unambiguous action that answers the question posed in the headline.
  • Make sure the question and the actions use the same words. Avoid using disjointed language. For example, if you ask, "Delete portfolio?" in the header, the primary CTA should also read "Delete."
  • Primary actions go on the right, dismissive or secondary actions on the left.
  • For modals that require a decision, use words that describe the literal action rather than something vague like Yes, OK or Sure.
  • Reserve "OK" for situations like acknowledgment modals, where you're simply asking the user to acknowledge the presented information.

Accessibility

The Jutro modal components are secondary window that appear over the primary window. They enable users to maintain the context of the primary task.

  • Screen reader interaction: The modal components include a WAI-ARIA role="dialog" and aria-modal="true" to indicate to assistive technologies that the window beneath is currently inert. Focus order, accessible names and programmatic relationships are dependent on the individual content within each modal. The element with ARIA role="dialog" includes both an aria-labelledby & an aria-describedby reference, which refer to the primary modal title & modal content respectively.
  • Keyboard interaction: When triggered, the tab sequence is contained & keyboard focus is trapped within the modal. The primary window is inert and cannot be interacted with until the modal is dismissed.
  • Color: The contrast ratio of textual elements against their background is above 4.5:1.
  • Zoom: All content is visible and functional up to & including a zoom factor of 200%.

This component has been validated to meet the WCAG 2.0 AA accessibility guidelines. However, changes made by the content author can affect accessibility conformance. Refer to the WAI-ARIA Authoring Practices for Modals, and within your application, be sure to check that:

  1. Upon triggering, keyboard focus is placed on the first focusable item within the modal dialogue.
  2. Upon dismissal, keyboard focus returns to the same component which triggered the modal dialogue.
  3. Focus should not move outside the modal until it is closed.