Skip to main content

Modal

Usage

Overview

Modals focus a user's attention on one task using 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.

For a detailed guide on when to use the modal component, explore the following UI component decision tree.

UI component decision tree for
modal

When to use

  • To request essential input or decisions that are blocking the user from continuing a process or task.
  • To deliver urgent information, critical errors, or important warnings that require immediate user attention and acknowledgement.
  • To confirm significant user actions, especially those with important consequences (for example, deleting data).

When not to use

  • For non-critical messages, status updates, or information that does not require immediate user action or workflow interruption.
  • To interrupt high-stakes or fluid user tasks (like a checkout process or complex data entry) unless absolutely necessary to prevent a critical error.
  • If the decision or task within the modal requires users to access other information on the page or elsewhere in the application.

Formatting

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.

Errors

Error messages must follow error messaging guidelines. For more information, see the following:

Content

General writing guidelines

  • Use sentence case for all aspects of designing Guidewire product interfaces. Don't use title case.
  • Use present tense verbs and active voice in most situations.
  • Use common contractions to lend your copy a more natural and informal tone.
  • Use plain language. Avoid unnecessary jargon and complex language.
  • Keep words and sentences short.
  • Headers must 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; for example, "Send payment?"

Body

  • Body text must clarify any consequences and explain options in simple terms.
  • Ensure the modal has all the information that is needed for a single decision.
  • 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 must be clear and straightforward.

Buttons

  • Primary button text must state an unambiguous action that answers the question posed in the header.
  • 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 call-to-action button (CTA) must 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.
This modal clearly asks about the specific action, informs the user of a key potential consequence, and offers unambiguous, action-oriented buttons.
This modal uses a vague question, fails to mention important consequences, and provides unclear 'Yes/No' button options.

Behaviors

States

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

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

When the modal is closed, the user is returned to the on-page content and their previous workflow.

Interactions

Mouse

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.

Keyboard

When triggered, the tab sequence is contained and keyboard focus is trapped within the modal. The primary window is inert and cannot be interacted with until the modal is dismissed.

Screen reader

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 and an aria-describedby reference, which refer to the primary modal title and modal content respectively.

Accessibility

The contrast ratio of textual elements against their background is above 4.5:1 as per WCAG 2.1 AA requirements. Non-textual content that needs to convey meaning (such as icons and keyboard focus visibility) has a contrast ratio of at least 3:1 with its adjacent colors. All content is visible and functional up to and including 400% without requiring scrolling in two dimensions.

This component has been validated to meet the WCAG 2.1 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:

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