Skip to content

TXT-002a Let people close, hover and keep content that appears on hover or focus

Level
Rule
Verdict
Requirement
Area
Text
Status
decided, version 1.0.0

Rule

Content that appears on hover or keyboard focus can be closed without moving the pointer or focus, usually with Escape. If hover opens it, the pointer can move onto it without it closing. It stays until the hover or focus that opened it ends, the person closes it, or it is no longer true.

Examples

Live examples built with Justified's components. Try them with the mouse, the keyboard or a screen reader.

Do: The card can be reached and closed with Escape

Comments on Checkout redesign

  • Priya Shah 2 hours ago

    The new card form saves a step. Can we test it with five customers this week?

  • Leon Park 1 hour ago

    Yes. I can have a build ready by Wednesday.

Rest the pointer on Priya Shah: a card opens flush against her name. Move the pointer onto the card: it stays as long as you rest there. Tab to a name and press Escape: the card closes and focus stays on the name. Tab on and it closes too. On Copy link, Escape hides the tooltip and Enter still copies.

Don't: A gap that closes the card on the way

Comments on Checkout redesign

  • Priya Shah 2 hours ago

    The new card form saves a step. Can we test it with five customers this week?

  • Leon Park 1 hour ago

    Yes. I can have a build ready by Wednesday.

Rest the pointer on Priya Shah: a card opens 12 pixels below her name. Move the pointer down to read it: the card closes as soon as the pointer leaves the name, so it can never be reached. Escape and Tab close it as they should; the gap is the fault.

Why

A tooltip, a hover card or a link preview can cover what the person is reading or about to click. If the only way to get rid of it is to move the pointer, someone who uses a screen magnifier loses their place, and a keyboard user has to Tab away from the control they meant to use. If the content closes as soon as the pointer leaves the trigger, a person who needs a large cursor or high zoom cannot move onto it to read it. If it closes on a timer, slow readers miss it. WCAG 2.2, 1.4.13 Content on Hover or Focus requires all three conditions. Whatever closes the content must itself work from the keyboard, which supports 2.1.1 Keyboard. TXT-002b covers when a tooltip opens and what it may hold.

Do

  • An icon button with the accessible name "Copy link" shows the tooltip "Copy link" on hover and on focus. Pressing Escape hides the tooltip while focus stays on the button, so the next Enter still copies the link.
  • A name in a comment thread, such as Priya Shah, opens a hover card with her role and team. The card sits right against the name, so the pointer can slide onto it and rest there while the person reads.
  • A link to the document Budget 2027 shows a preview on hover. The preview stays as long as the pointer is on the link or the preview, however long that takes.
  • A meeting in a shared calendar opens a hover card that names the room, Oak room. When the organiser cancels the meeting, the card closes, because what it showed is no longer true.
  • A short delay before closing, after the pointer has left both the trigger and the content, is fine. It makes the path from trigger to content forgiving.
  • When focus opened the content, close it as soon as focus moves on, so it never lingers over the element that now has focus. KBD-002 covers what may hide the focused element.
  • Inside a dialog, let the first Escape close only the open tooltip or hover card, and the next one close the dialog, as DLG-001 does for other popups.
  • If you use shadcn's Tooltip or HoverCard, check in your own build that Escape closes the content, that the pointer can reach it without a gap closing it, and that no wrapper or custom delay changes this.

Don't

  • Hide a hover card only when the pointer moves away, with no key that closes it.
  • Leave a gap between the trigger and the tooltip, so the content closes on the way there.
  • Close a link preview after a fixed number of seconds while the pointer still rests on it.
  • Make Escape close the whole dialog while a tooltip inside it is still open.
  • Keep a tooltip that focus opened on screen after focus has moved on, so it covers the newly focused field.

Exceptions

  • Content the browser draws. A tooltip the browser draws and the author does not restyle, such as the one from the title attribute, is not covered. That is no reason to choose it: it does not open on keyboard focus, and under ACT-001b it must not be a button's name.
  • Errors and content that covers nothing. The need to close without moving does not apply when the content reports an input error, or when it covers nothing that matters, not even its own trigger. It must still be hoverable and stay. FRM-002a already asks for field errors as visible text at the field.
  • Out of scope. Content opened by a click, a tap or Enter, such as a toggletip, a popover or a menu, is not covered. Neither is an element that is hidden until it gets focus, such as a skip link, or a modal dialog.
  • Not decided here. Whether content that appears on hover may hold links or buttons is not covered by this rule.

Verdict

Requirement. Only the judges decide; the expert witnesses are shown but do not vote. How verdicts work

Stances on TXT-002a
SourceRoleStancePage
WCAG 2.2LawRequires1.4.13 Content on Hover or Focus
WCAG 2.2LawSupports2.1.1 Keyboard
Material DesignJudge No position
Apple Human Interface GuidelinesJudge No position
Carbon Design SystemJudge SupportsTooltip: usage
Tooltip: accessibility
GOV.UK Design SystemExpert witness No position
Nielsen Norman GroupExpert witness No position

Each stance links to the page it rests on, read on the date in the source register. This page never repeats what a source says; read the source itself.

History

  • Version 1.0.0, : First version.

Last checked against the other rules for conflicts on .

More in Text: 4 rules and 0 guidelines · All rules