Overlay · astro-ui · HoverCard

HoverCard

Rich preview card on hover and keyboard focus — CSS-only.

HoverCard is the CSS-only sibling of Popover: content that appears after a short delay when the user hovers or focuses the trigger. Unlike Tooltip the card stays interactive (links inside work) and carries an aria-label so assistive tech can announce it. Because it is pointer-driven, never put essential information only in a HoverCard — the trigger itself must carry the primary content.

Features

  • Zero JS — pure CSS :hover / :focus-within with an open delay
  • Interactive content: links inside the card work
  • top / bottom placement; symmetric show/hide delay (no flicker)
  • role="note" + aria-label announced on focus

Usage

---
import { HoverCard } from "astro-ui";
---

<HoverCard ariaLabel="Profile preview">
  <a href="/users/ada">@ada</a>
  <div slot="content">
    <strong>Ada Lovelace</strong>
    <p>Notes on the Analytical Engine.</p>
  </div>
</HoverCard>

Demos

Basic

@ada

Ada Lovelace

Notes on the Analytical Engine.

<HoverCard ariaLabel="Profile preview">
  <a href="#">@ada</a>
  <div slot="content"><strong>Ada Lovelace</strong><p>Preview copy…</p></div>
</HoverCard>

Top placement

@grace

Grace Hopper

Compiler pioneer, US Navy.

<HoverCard placement="top" ariaLabel="Profile preview">
  <a href="#">@ada</a>
  <div slot="content"><strong>Ada Lovelace</strong><p>Preview copy…</p></div>
</HoverCard>

API

Props

PropTypeDefaultDescription
placement"top" | "bottom""bottom"Placement of the card relative to the trigger.
classstring—Merged via cn(); Tailwind classes welcome.
idstring—Element id.
ariaLabelstring—Accessible name.

Slots

SlotDescription
defaultThe trigger content (focusable).
contentThe preview card.

Accessibility

Implemented accessibility features — semantics, ARIA wiring, and keyboard behavior that ship with the component.

  • Hover content is a role="note" region
  • Triggerable from keyboard focus, not only pointer hover

FAQ

Can I put essential info in it?

No — it's pointer-driven and dismissible. The trigger must carry the primary content; the card is an enhancement (same rule as Tooltip).

Changelog

Version history mentioning HoverCard.

v0.1.0 — 2026-11-11
added
  • Overlay (8): Dialog, AlertDialog, Sheet, Tooltip, Popover, HoverCard, Lightbox, Menu.