Best Practices for Modals Overlays Dialog Windows

Why did I choose this article?

  1. How front end engineers are positioned in the outside world today. A lot of people think that the front-end should talk about architecture, but it’s not just that. We shouldn’t ignore the interactive experience.
  2. Front-end engineers have never stopped looking for user experience, and there has been a lot of controversy over the appearance of modal boxes in products, and I want to know what we think about that.

2 Content Summary

A modal box is an element located at the application window level. It creates a mode that keeps itself displayed under an outermost child view and disables the main window. The user must interact with it before returning to the main window.

The use of modal boxes

  • Capture the user’s appeal
  • Requires user input
  • Display additional information in context
  • Do not display additional information in context

Do not use modal boxes to display error, success, or warning messages. Keep them on the page.

The composition of the modal box

  • Way to exit. It could be a button on the modal box, it could be a key on the keyboard, it could be an area outside the modal box.
  • Descriptive titles. The title actually gives the user context information. Let the user know where he is currently operating.
  • The contents of the button. It has to be actionable and understandable. Don’t try to confuse the user with the contents of the button. If you try to do a cancel action and there is a cancel button in the box, do I cancel a cancel or do I continue with my cancel?
  • Size and location. The size of the modal box should not be too large or too small. The position of the modal box is recommended in the upper middle of the window, because too low on the mobile end will lose a lot of information.
  • The focal point. The appearance of the modal box must attract your attention, it is recommended that the focus of the keyboard also switch to the box.
  • User initiated. Do not frighten users. Use user actions, such as a button click, to trigger the appearance of a modal box.

The modal box is on the mobile side

Modal boxes don’t always work well on the mobile end. One reason is that modal boxes are generally too large and take up too much space. It is recommended to add a device button or built-in scroll bar to operate, the user can move left or zoom in and out to grasp the modal box.

Frictionless access

  1. Shortcuts. We should consider adding shortcuts to modal boxes for open, move, manage focus and close.
  2. ARIA. Add aria identifiers at the front code level, such as Role = “dialog”, ARIA-hidden, aria-label

Modal frame positioning

First, models and Toast, Notification, Message, and Popover are all triggered to pop up a floating layer at some point in time, but it is different from Modal. By definition, none of the above components are modal boxes, because modal boxes have the important property of blocking the original action in the main window and only doing subsequent actions in the box. In other words, the modal box completely interrupts user flow from the interface.

Of course, this is also the issue we need to discuss, if it is just a general message alert, you can use message bars, red dots and other forms of interaction, at least not blocking user operations. In the 10 Guidelines to Consider when using Overlays quoted at the end of the original lays, article 8 emphasizes that modal frames should never be used. What are the situations where you really want him to stay on the page and read or do something inside the box?

Conversely, what are the advantages of modal boxes? Remember that modal boxes are a much lighter experience than page jumps. For example, when a user sees a product on Taobao and wants to log in and buy it, the experience of the login modal box popping up is much better than that of jumping to the login page, because the user can directly purchase the product after logging in the modal box. Secondly, the content of the modal box is a derivative or supplement to the current page, allowing users to read or fill in some content more intently.

That said, when timed, a smooth pop-up experience, the necessary context information, and friendly exit feedback can all improve the experience. The modal box is intended to attract attention, but it must provide additional information, either an important user action or an important protocol confirmation. You can complete the process or information on this page.

Rethinking accessibility

Accessibility Accessibility is the improvement of the experience for different end users. For each modal box, there should be a function to close it via the keyboard, usually using the ESC key. It seems that we programmers somehow carry our own stereotypes into the implementation of the product, especially when we’re tapping on an external keyboard and using a PC.

The following questions are reflections on accessibility:

  • Maybe the user doesn’t have a mouse, or a keyboard, or maybe they don’t have either mouse or keyboard, and they just use voice control? How do you get those users to quit
  • Many Windows PCS already have good touch support, but your web page still only supports keyboard and mouse?
  • Is a horizontal scrollbar an outlandish design without an Apple trackpad?
  • In a web page, using Command(Ctrl) and +/- and using the touchpad zoom events are two different representations, right?
  • If your end user doesn’t have a good touch pad, but he really can’t see what’s on your web page. If he uses the former, can you make sure your site still displays the content?

Accessibility has always been a product that has been grossly neglected, and the emphasis on how it is done at the end of the article’s Best Practices is a good nudge for us developers.

Additional reading