Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Pick a Popover or a Dialog

In this lesson, you watched what the page behind each of Kwame’s three components does while it’s open, and used that to ask whether the cancel question could have been a popover, or the help tip a dialog:

  • A popover leaves the page usable. With the condition help tip open on the step ladder’s page, nothing behind it is dimmed. When Tomasz Nowak clicks the Reserve from December 12 button, on the page below the tip, the click works and the notice opens. The tip closes by light dismiss.
  • Focus stays on the page. With the keyboard, Enter opens the tip, and Tab moves on to the About safety button, hidden behind the centered tip, while the tip stays open. Esc closes the tip and shows the focus ring on About safety. Placing the tip next to its button, so it covers nothing, comes in the next section. Watch out: however much a popover looks like a dialog, it can’t make the page wait.
  • A modal makes the page wait. On My Reservations, Enter on Cancel step ladder opens the modal over a dimmed page and moves focus to Keep it. A click on Cancel hedge trimmer through the backdrop does nothing, because the page behind a modal is inert. Esc would close it, but Mei Lin Chen can’t skip past it to the page. While it’s open, the accessibility tree holds only the dialog, with its heading, its text and its two buttons.
  • What a screen reader gets from a popover. With the tip open, Chromium’s full-page accessibility tree (November 29, 2026) still holds the whole page, About safety included, with the tip’s text right after its button. Nothing is inert, so a screen reader can read the tip and then carry on. With your screen reader, listen for a button named About condition that changes from collapsed to expanded.
  • Animation. Popovers and dialogs can both animate their opening with @starting-style, which is Baseline Newly available.

Ask what the page behind should do. If it must wait until someone answers or closes the box, use a modal dialog. If they can carry on, use a popover: an auto popover for help that can go when they click away, and a manual one for a notice that has to stay until it’s closed.

So the cancel question stays a modal dialog, the help tip an auto popover, and the saved notice a manual one.

00:00 In the last lesson, you turned the step ladder’s help text into an auto popover, and its Reservation saved notice into a manual one. Before that, you gave My Reservations a modal cancel dialog.

00:13 All three open in the top layer, above the page. So could the cancel question have been a popover, or the help tip a dialog? Watch what the page behind each one does while it’s open.

00:26 Tomasz Nowak is on the ladder’s page. He clicks the About condition button, the question mark next to Condition, and the tip opens over the page. Nothing behind it is dimmed.

00:38 Then he clicks the Reserve from December 12 button, on the page below the tip. The click works, so the notice opens. The tip closes by light dismiss.

00:48 With the keyboard, Enter opens the tip again, and Tab moves on to the About safety button, hidden behind the centered tip. The tip stays open. Escape closes it, and there’s the focus ring on About safety.

01:02 Placing the tip next to its button, so it covers nothing, comes in the next section. Watch out: however much a popover looks like a dialog, it can’t make the page wait.

01:15 A cancel question needs exactly that. On My Reservations, Mei Lin Chen presses Enter on the Cancel step ladder button. The modal opens over a dimmed page, and focus moves into it, to the Keep it button.

01:29 She clicks the Cancel hedge trimmer button through the backdrop. Nothing happens, and focus lands on the dialog itself, which shows no ring. The page behind a modal is inert, so it waits until the dialog closes.

01:42 Escape would close it, but she can’t skip past it to the page. The accessibility tree agrees. With the modal open, it holds only the dialog, with its heading, its text and its two buttons.

01:57 Back on the ladder’s page, the tip is open again. The modal’s tree held only the dialog. So with the tip open, is the About safety button still in the page’s accessibility tree?

02:09 Your turn: pause the video and predict.

02:16 Yes, the whole page is still there, with the tip’s text right after its button. Nothing is inert, so a screen reader can read the tip and then carry on. With your own screen reader, listen for a button named About condition that changes from collapsed to expanded.

02:34 Popovers and dialogs can both animate their opening with the CSS rule @starting-style, which is Baseline Newly available. That’s all you need about it for now.

02:45 Ask what the page behind should do. If it must wait until someone answers or closes the box, use a modal dialog. If they can carry on, use a popover. Then pick the popover’s kind.

02:58 An auto popover fits help that can go when they click away. A manual one fits a notice that has to stay until it’s closed. So the cancel question stays a modal dialog, the help tip an auto popover, and the saved notice a manual one.

03:15 Next, in Exercise: Build the Help Tip and Saved Notice, you’ll build both, and pick the right element for a cancel question too.

Become a Member to join the conversation.