ebnsina

Hover Card

Cards

About

A link preview card that opens on hover or keyboard focus to show extra detail about where the link leads, positioned beside the trigger with the native Popover API.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Hover Card to your project and fits it to your theme.

Code

How Hover Card is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

import HoverCard from "@/components/ui/hover-card";

// Ported from the project's own 'basic' example (src/routes/components/hover-card/examples/basic.svelte).
// "Ibn Sīnā" -> "IS": the original Avatar component's initials logic, reproduced here for demo content only.
function initials(name: string) {
  return name
    .split(/\s+/)
    .filter(Boolean)
    .filter((_, i, all) => i === 0 || i === all.length - 1)
    .map((w) => [...w][0].toLocaleUpperCase())
    .join("");
}

function DemoAvatar({ name }: { name: string }) {
  return (
    <span className="hc-demo-avatar" role="img" aria-label={name}>
      <span aria-hidden="true">{initials(name)}</span>
    </span>
  );
}

export default function HoverCardDemo() {
  return (
    <div className="hc-demo-text">
      The theory of vision was rewritten by{" "}
      <HoverCard
        trigger={(props) => (
          <a href="#basic" {...props}>
            Ibn al-Haytham
          </a>
        )}
      >
        <div className="hc-demo-person">
          <DemoAvatar name="Ibn al-Haytham" />
          <div>
            <strong>Ibn al-Haytham</strong>
            <span className="hc-demo-dates">
              c. 965 – c. 1040 · Basra and Cairo
            </span>
          </div>
        </div>
        <p className="hc-demo-about">
          Showed that we see because light enters the eye, and tested it by
          experiment in his Book of Optics.
        </p>
        <p className="hc-demo-more">
          Holdings: 4 manuscripts, Bayt al-Ḥikma reading room ·{" "}
          <a href="#basic">Read more</a>
        </p>
      </HoverCard>{" "}
      in the early 11th century.
    </div>
  );
}

More by ebnsina

View all
  • Countdown Timer

    Countdown Timer

    26
  • Video Player

    Video Player

    20
  • Alarm Clock

    Alarm Clock

    19
  • Voice Note

    Voice Note

    12
  • Split Button

    Split Button

    11
  • Sortable List

    Sortable List

    11
  • Code Block

    Code Block

    8
  • Sign In Auth Card

    Sign In Auth Card

    6

More in Cards

View all
  • Course Design Cards

    Course Design Cards

    1.1K
  • Interactive Tech Stack Bento Grid with Hover Effects

    Interactive Tech Stack Bento Grid with Hover Effects

    271
  • Statistics Card 2

    Statistics Card 2

    279
  • Statistics Card 7

    Statistics Card 7

    302
  • Card Studio

    Card Studio

    14
  • Stats cards with links

    Stats cards with links

    125
  • Statistics Card 10

    Statistics Card 10

    272
  • Weather Card

    Weather Card

    60