Skip to content

Hover Card

Get Ritla UI

A read-only preview of what a link points to, shown while the pointer rests on it or it has focus.

Ritla scan of this preview: 41 of 41 checks3 breakpointsScanned

Open in Figma

Preview

Mirrored is the same English content laid out right to left: it separates a mirroring bug from a translation one.

PreviewCode
EnglishMirroredArabic
LTR →

Installation

  1. Add the component

    npx ritla add hover-card

    Also works with shadcn: npx shadcn@latest add @ritla/hover-card

  2. Dependencies it brings

    @base-ui/react@phosphor-icons/react

  3. Or copy by hand

    Installing by hand copies the component's source into your project. The source comes with a Ritla UI license, so the CLI is the short way to the same files.

Usage

hover-card.tsx
import { HoverCard, HoverCardContent, HoverCardProfile, HoverCardTrigger } from "@/components/ui/hover-card";<HoverCard>  <HoverCardTrigger href="/people/noor">Noor Al-Hassan</HoverCardTrigger>  <HoverCardContent>    <HoverCardProfile name="Noor Al-Hassan" handle="@noor.designs" bio="Product designer in Amman." />  </HoverCardContent></HoverCard>

Examples

A merchant, on top

side="top" on a transaction row. The domain stays left to right; the numbers follow the numerals setting.

EnglishMirroredArabic
LTR →

API reference

HoverCardTrigger

PropTypeDefaultDescription
hrefstringNoneThe link: it still navigates on click or tap.
delaynumber500How long the pointer rests on the link before it opens (ms).
closeDelaynumber300How long it stays after the pointer leaves the link and the card.
renderReactElementNoneYour own link, e.g. Next's <Link />.

HoverCardContent

PropTypeDefaultDescription
childrenReactNodeNoneRead-only content: no buttons, links or fields.
side"bottom" | "top" | "start" | "end""bottom"Figma's Side. Flips when there isn't room.
align"start" | "center" | "end""center"Where it lines up along that side.
arrowbooleantrueThe arrow, pointing at the link.

HoverCardProfile

PropTypeDefaultDescription
namestringNoneFigma's Name, and the avatar's initials.
handlestringNoneFigma's Handle: a handle or domain, left to right.
srcstringNoneThe photo; without it, the initials.
bioReactNodeNoneFigma's Bio: about two lines.
facts{ icon?; label }[]NoneFigma's Meta: short facts with an icon.

Accessibility

Keyboard

Keys are written for left-to-right. In right-to-left the arrow keys swap: the one pointing toward the reading direction moves forward.

KeyAction
TabFocusing the link opens it after the delay; leaving it closes it.
EscCloses it; focus stays on the link.
EnterFollows the link.

ARIA

  • The card is a visual extra: everything in it is on the page the link opens, so screen reader users miss nothing.
  • Nothing interactive inside: it closes when the pointer or focus leaves the link.
  • On touch screens a tap follows the link.

Arabic and RTL notes

Mirrors

  • The avatar comes first: on the right, the text after it.
  • Facts start on the right, the icon before each label.

Does not mirror

  • Handles and domains (@noor.designs) stay left to right.
  • The location and calendar icons don't mirror.
Numerals
Years and counts in facts follow the numerals setting; format them with formatNumber.
Arabic typography
Name label-16 Semibold, handle label-14, bio body-14, facts label-12.
Mixed-direction text
The name goes in <bdi>, the handle in <bdi dir="ltr">, and the bio gets dir="auto" since it can be in either language.

Checks it passes

The Ritla checks this component satisfies by construction. Used as documented, it does not bring these defects onto your page.

  • R042Clipped text: content wider than its box with overflow hidden and no ellipsis
  • R043Fixed-pixel-width container whose Arabic text exceeds the space
  • R050Arabic text falling back past the declared font family (measured, declared, or a webfont that failed to load)
  • R051letter-spacing applied to Arabic text (breaks the connected script)