Skip to content
Vertical Jump Designs-uiFront-End Studio
Get Pro

v3.9 is out.

Overlays

HoverCard

Free14.0 KB gzipped

Accessibility: WCAG 2.2 AA · No A or AA violations in light or dark mode · Keys: Tab, Escape · Full report

Import

tsx
import { HoverCard } from "@vjdesigns/vjdesigns-ui";

Importing only HoverCard adds about 14.0 KB of minified, gzipped JavaScript to your app (React not included). The stylesheet is shared by every component and loaded once: 75.1 KB gzipped.

Examples

Basic

A preview that opens while the pointer rests on the link, or while it has keyboard focus. Move the pointer onto the card and it stays; Escape closes it. Touch screens have no hover, so a tap just follows the link: keep everything in the card reachable from the page it links to.

Tonight's starter is Jordan Reyes, back from a sprained ankle.

tsx
import {
  Avatar,
  Flex,
  HoverCard,
  Link,
  Stack,
  Text,
} from "@vjdesigns/vjdesigns-ui";

export function Basic() {
  return (
    <Text>
      Tonight&apos;s starter is{" "}
      <HoverCard>
        <HoverCard.Trigger>
          <Link href="#example-basic">Jordan Reyes</Link>
        </HoverCard.Trigger>
        <HoverCard.Content>
          <Flex gap={3} align="center">
            <Avatar name="Jordan Reyes" colorFromName />
            <Stack gap={1}>
              <Text weight="semibold">Jordan Reyes</Text>
              <Text size="sm" tone="muted">
                Point guard · 18.4 points per game
              </Text>
            </Stack>
          </Flex>
        </HoverCard.Content>
      </HoverCard>
      , back from a sprained ankle.
    </Text>
  );
}

Right to left

The first example again, inside a right-to-left LocaleProvider (Arabic). Layout, spacing and arrow icons mirror, and the components' built-in text is translated. The example's own text stays in English.

Basic

Tonight's starter is Jordan Reyes, back from a sprained ankle.

tsx
import { LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import ar from "@vjdesigns/vjdesigns-ui/locales/ar";

// Basic is the "Basic" example above.
<LocaleProvider locale="ar" messages={ar}>
  <Basic />
</LocaleProvider>

API reference

HoverCard

New in 1.5.0
HoverCard props
PropTypeDefault
children

HoverCard.Trigger and HoverCard.Content.

ReactNode—
open

Controlled open state.

boolean—
defaultOpen

Initial open state when uncontrolled.

booleanfalse
onOpenChange

Called with the next open state.

(open: boolean) => void—
openDelay

Delay before opening on hover or keyboard focus, in ms.

number500
closeDelay

Delay before closing after the pointer leaves the trigger or the card, in ms. Gives the pointer time to cross the gap onto the card.

number300

HoverCard.Trigger

New in 1.5.0
HoverCard.Trigger props
PropTypeDefault
childrenRequired

Exactly one focusable element, usually a Link (or a button) that accepts ref, event handlers, and data-* props. Its own handlers and ref are kept.

ReactElement—

HoverCard.Content

New in 1.5.0
HoverCard.Content props
PropTypeDefault
placement

Preferred side and alignment. Flips to the other side when there isn't room.

"top""top-start""top-end""bottom""bottom-start""bottom-end""left""left-start""left-end""right""right-start""right-end""bottom"
offset

Gap between the trigger and the card, in px.

number8
size

Maximum width and padding: sm 16rem, md 20rem, lg 30rem.

"sm""md""lg""md"
showArrow

Show an arrow pointing at the trigger.

booleanfalse
container

Element to portal into.

HTMLElement | nulldocument.body

Also accepts native <div> attributes, plus className, style and ref.

See what changed in each version in the Changelog.

Accessibility report

HoverCard targets WCAG 2.2 AA. Below: a live axe-core audit of this page's examples, Lighthouse scores for the page in both modes, the accessibility behavior built into the component, and the checks only a person can do.

axe-core audit (live)

Running accessibility audit

Checking the examples above…

Lighthouse audit

Light mode

Score 100

35 passed · 0 failed · 30 not applicable · 10 to check by hand

Dark mode

Score 100

35 passed · 0 failed · 30 not applicable · 10 to check by hand

Lighthouse 13.5.0 audits the whole docs page (header and sidebar included), not just the examples, in English. Last run 11/27/2026. Some failed audits carry no weight in the score, so a page can score 100 and still list one.

Built-in behavior

Keyboard

Keyboard
KeyAction
TabFocusing the trigger opens the card; Tab moves into its links and buttons, and past the last one continues after the trigger.
EscapeCloses the card.

Meets WCAG 1.4.13: the pointer can move onto the card, it stays open while hovered or focused, and Escape dismisses it. It never opens from a tap, so its content must also be reachable from the page the trigger leads to.

Roles and states

Roles and states
ElementRoleStates and properties
TriggerIts own (link or button)Left untouched: the card is a preview, not part of its name
Cardnone (generic)Rendered after the trigger in focus order

Manual checks

Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.

Manual accessibility checks
CheckWhat to testWCAG 2.2
KeyboardEvery action works with Tab, Shift+Tab, Enter, Space and the arrow keys, and focus never gets stuck.2.1.1 (A), 2.1.2 (A)
FocusFocus moves in a logical order, is always visible, and isn't hidden behind sticky headers.2.4.3 (A), 2.4.7 (AA), 2.4.11 (AA), 2.4.13 (AAA)
Screen readersNames, roles and states are announced correctly, and status changes are announced without moving focus.1.3.1 (A), 4.1.2 (A), 4.1.3 (AA)
ColorMeaning never depends on color alone; your own colors meet contrast in both modes.1.4.1 (A), 1.4.3 (AA), 1.4.11 (AA), 1.4.6 (AAA)
Zoom and reflowAt 200% text size and at 320px wide (400% zoom), nothing is cut off and no sideways scrolling is needed.1.4.4 (AA), 1.4.10 (AA), 1.4.12 (AA)
Pointer targetsClick and tap targets are at least 24×24px (44×44px for AAA), or spaced so they don't overlap.2.5.8 (AA), 2.5.5 (AAA)
MotionAnimations respect the reduced-motion setting.2.3.3 (AAA)