Modals

A Modal is a dialog that takes over the screen. It requires action before the user can move on to other tasks.

Do

Modals should be used for actions that require the user’s attention, such as:

  • Confirming deletion or other dangerous actions
  • Showing critical information
  • Prompting a decision from the user when one is required to complete a task
Don't

Modals should not be used for low-priority things like:

  • Showing that something has been updated. Consider using a Toaster instead.
  • Configuration. This should be shown on a page instead of hidden in a modal.

Accessibility

It should be possible to use the modal using only the keyboard. Consider:

The following example using <fun-modal> and <fun-modal-controller> does all of this. Try using the keyboard.

Standard Modals

A standard modal has a header, body, and a footer. The footer should contain:

If the modal has no primary action then the footer should contain a ‘Close’ primary button. The button should follow the rules of the primary button above and also:

Should be presented when asked to delete an item.

The button should follow the rules of the primary button above and also:

Really strict modal

To force the user to make a choice remove the ‘close’ button and do not allow closing with the ‘escape’ key or clicking outside the modal.

Set closeOnClickOutside={false} and closeOnEscape={false} on <fun-modal-controller />, and closeButton={false} on <fun-modal /> to achieve this.

Modals with a secondary action

For modals with a secondary action other than the primary action or cancel, the secondary action:

Modals containing wizards

Models containing a wizard should have:

Hero modals

A “hero modal” is a special kind of modal that displays a preview or a visual to further explain whatever the modal is going to do.

Read more in fun-hero-modal

Implementation

For implementation details see web components:

Search Gunnel

Powered byAlgolia