videorc/ui

Hover Card

A preview of what a link points at, shown on hover or focus, on the popup tier of the float glass. Base UI's Preview Card under shadcn's name.

Streaming to Twitch

Installation

$ pnpm dlx shadcn@latest add @videorc/hover-card

Usage

import {
  HoverCard,
  HoverCardContent,
  HoverCardTrigger,
} from "@/components/ui/hover-card";
<HoverCard>
  <HoverCardTrigger href="https://www.twitch.tv">Twitch</HoverCardTrigger>
  <HoverCardContent>Live for 1:12:04 at 6,000 kbps.</HoverCardContent>
</HoverCard>

The trigger is a link. Set how long it waits with delay and closeDelay on the trigger: a status bar's destinations use 400 ms and 80 ms, so the cards keep up as the pointer runs along the bar.

Anatomy

<HoverCard>
  <HoverCardTrigger />
  <HoverCardContent />
</HoverCard>

Theming

Token or attributeMeaning
glass-floatThe popup tier: the window's solid tone, a 1 px rim and the float drop
rounded-lgThe popup tier's 10 px corners
w-72, p-3Its default width and padding
data-open, data-closedFades and scales from 0.98 in 100 ms, with no slide

Keyboard

KeyAction
TabFocusing the trigger opens the card
EscapeCloses the card

Accessibility

The card is a sighted user's preview. Keyboard and screen reader users reach the link, not the card, so never put the only copy of a fact or an action in it.

API reference

Every Base UI Preview Card prop, plus:

HoverCardTrigger

Prop

Type

HoverCardContent

Prop

Type