How can I display an inline notification that users can dismiss by keyboard?
Quick answer
Give the notice a clearly named, keyboard-reachable dismiss button with a visible focus indicator. Decide where focus should go when dismissal removes the focused button: if a control opened the notice, returning focus there may fit; for a notice with no opener, choose a sensible remaining location and test it. Microsoft documents specific focus and Escape behavior for WinUI popups, not for every web notice, so adapt and verify behavior in your own interface.
The question, the details, the next step.
A practical checklist
Name the dismiss control clearly; don’t rely on an icon alone.
Check that keyboard traversal reaches the control in a predictable order.
Confirm the focused control has a visible focus indicator.
Choose and test a useful focus destination after the notice is removed.
Test the keys and optional Escape behavior for the actual platform and control.
A few more useful answers
Is an × icon enough to identify the dismiss control?
Not by itself. Give the interactive control a clear accessible name, such as “Dismiss notification,” and check that it is keyboard reachable.
Must every inline notice close when Escape is pressed?
The cited Escape guidance concerns a particular WinUI Popup behavior; it does not establish a universal rule for web inline notices. If you add Escape dismissal, keep a clear keyboard-reachable button as well.
Where should focus go if the notice has no opener?
Choose a useful element that remains after dismissal, based on the surrounding interaction, and test that choice. The cited popup guidance does not specify a general destination for an inline notice with no opener.
Sources
References used for this guide.
- [S1] Popup control — Windows apps | Microsoft Learn learn.microsoft.com · Checked
- [S2] Keyboard interactions — Windows apps | Microsoft Learn learn.microsoft.com · Checked
- [S3] Keyboard accessibility — Windows apps | Microsoft Learn learn.microsoft.com · Checked
