Expand description
A rich preview that opens on hover and can be reached.
§What separates this from a tooltip and from a popover
A Tooltip is help. It is never actionable, it
never holds the only copy of anything, and it is allowed to vanish the
instant the pointer leaves, because nobody was ever going to point at it.
A Popover is a surface you opened on purpose,
by clicking. It has no hover behaviour to get wrong.
A hover card is the awkward third thing: it opens by hover and holds content worth reaching — a link, a button, text to read. So the pointer has to be able to travel from the trigger into the card, and between the two there is a gap the surface does not cover. A card that closed the moment the pointer left the trigger would put its content behind a race the user loses every time, which is a broken component rather than a fussy one.
§The grace period
Two facts are tracked, not one: whether the pointer is over the trigger and whether it is over the card. Leaving both starts a countdown; entering either cancels it. Only a countdown that runs out closes the card, so the diagonal trip across the gap is a period during which the card is leaving and has not left, and arriving anywhere inside it calls the whole thing off.
Opening has its own countdown, for the opposite reason: a card that opened the instant a pointer crossed it would flash open and shut all the way across a row of them. Leaving the trigger before that countdown runs out cancels it, so a pointer passing through opens nothing.
Both durations are caller-settable and neither is a token: they are
reaction times, not paint, and nothing in crates/gpui-kit-tokens/tokens/*.json describes how
long a hand takes to cross two centimetres.
§The keyboard
Hover is not the only way in. The trigger is a tab stop; focusing it opens the card at once, with no delay, because a keyboard user did not wander there by accident. The card is a tab stop of its own so its content can be reached, and escape closes the card and hands the keyboard back to the trigger.
Structs§
- Hover
Card - A preview surface that opens on hover and can be pointed at.
Enums§
- Hover
Card Event - What a hover card reports. The owner decides what any of it means.
Constants§
- DEFAULT_
GRACE - How long the card survives with the pointer over neither surface.
- DEFAULT_
OPEN_ DELAY - How long a pointer has to rest on the trigger before the card opens.