Create

General

Hover Card

Copy page View as Markdown Open in ChatGPT Open in Claude

For sighted users to preview content available behind a link.

Usage#

app.component.ts
import { WdsHoverCardComponent } from '@wds/angular/hover-card';

Put a link in the trigger slot and the preview in the default slot. The card only previews: everything in it must also be on the page the link opens, because touch screens have no hover. For a short label use Tooltip, for content opened by a click Popover.

Examples#

Default#

The card opens when the pointer rests on the link for open-delay (default 500 ms) or the link gets keyboard focus, and closes close-delay (default 300 ms) after the pointer leaves the link and the card.

@octocat
OC
@octocat GitHub's mascot and the face of open source. Joined January 2011

Side#

side places the card bottom (default), top, left or right of the link, and align along it.

Left The card opens on the left. Top The card opens on the top. Bottom The card opens on the bottom. Right The card opens on the right.

User profile#

A person mentioned in the text. The card stays open while the pointer is over it, so its button can be clicked; with the keyboard, Tab moves from the link into the card. --wds-hover-card-width sets the width (default 16rem).

Assigned to Mira Stone
MS
Mira Stone Product designer · Lisbon
24Open
118Done
3dAvg. time
View profile
for review.

A preview of the page behind a link in running text.

Read the release notes
WDS 0.2: Tooltip, Popover and more Four new components, a shared positioning helper and faster docs. wds.example.com · 3 min read
before you upgrade.

Delay#

open-delay and close-delay set the delays in milliseconds.

No delay Opens and closes at once. 1 second Opens after the pointer rests for a second.

API References#

wds-hover-card#

A preview of content behind a link, shown when the pointer rests on the link or the link gets keyboard focus (e.g. a profile card for a

Attributes

AttributeTypeDefaultDescription
openbooleanfalseWhether the card is visible. Also set by show() and hide().
sideWdsHoverCardSide'bottom'Side of the trigger. Flips when there is not enough space.
alignWdsHoverCardAlign'center'Alignment along the trigger.
offsetnumber4Distance from the trigger in px.
open-delay.openDelaynumber500Delay in ms before the card opens when the pointer rests on the trigger.
close-delay.closeDelaynumber300Delay in ms before the card closes after the pointer leaves the trigger and the card.
disabledbooleanfalseTurns the card off.

Events

EventDescription
wds-open-changeCustomEvent<WdsHoverCardOpenChangeDetail>The card opens or closes.

Methods

MethodDescription
show()Shows the card.
hide()Hides the card.

Slots

SlotDescription
triggerThe element the card belongs to, usually a link.
(default)Card content. It follows the trigger in the Tab order.

CSS parts (::part)

PartDescription
contentThe card.

CSS custom properties

PropertyDescription
--wds-hover-card-widthWidth of the card (default 16rem).

Accessibility#

Screen reader#

The card is extra information for sighted users; screen readers read the link as usual. Its content follows the link in the reading and Tab order while it is open.

Do not put anything in the card that is not available after following the link: touch screens have no hover.

The card follows WCAG 1.4.13 "Content on hover or focus": the pointer can move onto it, Escape closes it, and it stays until the pointer or focus leaves.

Keyboard support#

KeyFunction
TabFocus on the link opens the card; the next Tab moves into the card. Focus leaving the link and the card closes it.
EscapeCloses the card; focus returns to the link.
Footer