UI tipsa handbook of interface patterns

08Feedback

Pop-up windows

A pop-up window, which designers call a modal dialog, stops everything else on the page until you deal with it. That is useful when you really need an answer before going on. It is irritating when the window only wants attention, like an offer to join a newsletter that jumps up the moment you arrive.

Updated:

On this page
  1. When a pop-up is the right choice
  2. The built-in dialog does the hard work
  3. Where the keyboard goes
  4. Clear words in the window
  5. On a phone
  6. Gentler options
  7. Before you move on
  8. Sources

When a pop-up is the right choice

Some questions absolutely do need an answer before anything else can go ahead. Someone closes a document without having saved it and you’re left having to ask whether to keep the changes. Someone wants to rename a file (takes 5 seconds and one box). Someone is in the middle of a payment and needs to sign in first. In those situations a small window over the page is the right thing to have, as opening up a whole new page would break their flow and could well result in them losing what they were doing.

For long forms, use a normal page instead. On a page people can scroll, go back and save a bookmark. If people want to compare the information with what is underneath, use a panel at the side or open the details right in the page.

And please don’t greet visitors with a pop-up they didn’t ask for. It covers the very thing they came to read. On phones, Google also counts these as a bad sign for a page.

Fig. 08.1Do and don’t

Don’t

How to brewfilter coffeeSubscribe for10% off!EmailSubscribe×

Do

How to brewfilter coffeeGet new articles by emailEmail addressSubscribe
If the visitor didn’t ask for it, it shouldn’t cover the page.

The built-in dialog does the hard work

Browsers now have a ready-made pop-up called dialog. When developers open it with showModal(), the browser takes care of the tricky parts. The page behind it can’t be clicked or reached with the keyboard while it is open. The Escape key closes it. The keyboard moves into the window by itself. The page behind gets dimmed, and screen readers tell blind users that a window has opened.

There is also a setting called closedby that decides whether a click outside the window closes it. That is handy for small windows. For a window where someone is typing, it is safer to leave it off, so a stray click doesn’t throw away their work.

Where the keyboard goes

When the window opens, the keyboard should land somewhere useful, like the first box to fill in or, for a “Delete?” question, the safer button. When the window closes, the keyboard should go back to the button that opened it. Otherwise keyboard users find themselves at the top of the page and have to work their way down again. The built-in dialog handles the first part. Test the second part yourself.

Fig. 08.2Annotated

FilesQ3 report.pdf⋯Budget 2027.xlsx⋯Team photo.jpg⋯Invoice 4512.pdf⋯Brand notes.docx⋯Contract draft.pdf⋯Rename fileFile nameQ3 report.pdfCancelRename1234567
  1. The title says what this is.
  2. The field is focused on open, its text pre-selected.
  3. The main action names the result: Rename.
  4. Cancel is secondary.
  5. The × close button is a 44 px target.
  6. Backdrop: the page behind is inert.
  7. Focus returns to the Rename menu item after closing.
Every part of a small pop-up has a job.

Clear words in the window

The title should be the question itself, not “Warning” or “Are you sure?”. “Delete this project?” tells people straight away what is at stake.

Below it, say what will happen: “The project and its 14 files will be removed. This can’t be undone.” Then name the buttons after what they do, “Delete project” and “Cancel”, rather than “Yes” and “No”. Someone who reads only the buttons should still choose correctly.

On a phone

On a computer, keep the window fairly narrow so the lines of text are comfortable to read. On a phone, let it fill the width of the screen or slide up from the bottom. When the keyboard opens, it can cover half the screen, so check that people can still scroll inside the window and reach its buttons.

Gentler options

Quite often you can do without the window altogether. If a deleted item can come back, delete it and show an “Undo” strip instead of asking first. If someone wants to change a single value, like the quantity in a basket, let them type it right there in the list. And once a task needs more than four or five boxes, give it a proper page of its own, where people can scroll and go back.

Before you move on

Open your pop-up and try to close it in three ways: with the cross, with the Escape key and, on a phone, with the back gesture. Then check where you end up. If any of those fails, or if you land somewhere unexpected, it needs fixing.

Sources