Hover Card

A richer card than a tooltip, for previewing something without leaving the page: a contact, a summary. Built on ui-sdk's Hover Card: it opens at once on hover or keyboard focus, stays open while the pointer moves onto it, and Escape closes it. It sits against its trigger, and leaves as it arrived, in reverse.

BetaReady to use. Its API can still change in a minor release; the changelog says when.

import { HoverCard, HoverCardTrigger, HoverCardContent } from "@leap-crm/design-system";

Playground

Change a prop and the component follows. Its code is under Props.

Props

padding
loading
side
align

Best practices

When to use it, and the rules that apply in particular places.

GuidancePractice
DoUse it to preview a record without leaving the page, like a contact's details on their name or the parties on an opportunity.
DoPass a link or a name to HoverCardTrigger's render, like a TextLink, so keyboard focus opens the card as well as hover.
DoSet loading while the content fetches. The small spinner card stays for at least one turn, then grows into the card.
DoUse padding="card" for text content, and leave it at none when the content sets its own, like a contact preview's status band.
Don'tPut an action in it that the page doesn't also offer. It only opens on hover or focus, so a lawyer on touch may never see it.
Don'tUse it for a one-line name or hint on a control. Use SimpleTooltip.

Props

HoverCard takes ui-sdk's options (open, defaultOpen, onOpenChange, delay, closeDelay, controller). HoverCardContent takes the position props (side, align, sideOffset, alignOffset, anchor, collisionPadding, keepMounted).

HoverCard

PropTypeDefaultDescription
delayunknown0

HoverCardContent

PropTypeDefaultDescription
childrenReactNode—What it shows inside.
padding"none" | "card""none"`card` for text content (16 / 12 padding); `none` when the content sets its own, like a contact preview's status band.
loadingbooleanfalseShows the 28 px loading card with a spinner while the content loads. It stays for at least one turn of the spinner, then grows into the card.
classNamestring—Classes added to the root element, merged with its own. Tokens only.
sideunknown"bottom"Which side it opens on. It flips to the other when there isn't room.
alignunknown"start"How it lines up along that side: start, center or end.

Code

What the playground shows, ready to copy.

import {
  HoverCard,
  HoverCardContent,
  HoverCardTrigger,
  TextLink,
} from "@leap-crm/design-system";

<HoverCard>
  <HoverCardTrigger render={<TextLink href="/contacts/ada">Ada Hartley</TextLink>} />
  <HoverCardContent padding="card">
    <p>Ada Hartley, client since 2024.</p>
  </HoverCardContent>
</HoverCard>

Contact preview

A 256 px card with a 36 px status band, a 40 px avatar over its edge, the name and a muted line, and detail rows with navy icons. No padding of its own: the content sets it.

Content card

padding="card" gives text content 16 / 12 padding.

What the examples share

The imports and the scaffolding the examples above call. The scaffolding lives in this page, not in the library.

import { BriefcaseBusiness, Mail, Phone } from "lucide-react";

import { useState } from "react";

import { Avatar, Badge, HoverCard, HoverCardContent, HoverCardTrigger, TextLink } from "@leap-crm/design-system";

const details = [
  { icon: <Mail />, label: "Email", value: "Not recorded" },
  { icon: <Phone />, label: "Phone", value: "0400 000 000" },
  { icon: <BriefcaseBusiness />, label: "Matter type", value: "Conveyancing" },
] as const;

function ContactPreview() {
  return (
    <div className="w-64">
      <div className="bg-neutral-surface-subtle flex h-10 items-center justify-end px-3">
        <Badge tone="info">Client</Badge>
      </div>
      <div className="flex flex-col gap-1 px-4 pb-4">
        <Avatar
          name="Ada Hartley"
          initials="AH"
          size="xl"
          className="ring-neutral-surface -mt-5 ring-2"
        />
        <span className="text-body font-book">Ada Hartley</span>
        <span className="text-caption text-neutral-text-muted">
          Client · Agency Purchase
        </span>
      </div>
      <ul className="border-neutral-divider m-0 flex list-none flex-col gap-2 border-t px-4 py-4">
        {details.map(detail => (
          <li key={detail.label} className="flex items-start gap-2">
            <span className="text-brand-navy mt-0.5 [&_svg]:size-3.5">
              {detail.icon}
            </span>
            <span className="flex flex-col">
              <span className="text-caption text-neutral-text-muted">
                {detail.label}
              </span>
              <span className="text-caption">{detail.value}</span>
            </span>
          </li>
        ))}
      </ul>
    </div>
  );
}

function Loading() {
  const [loading, setLoading] = useState(true);
  return (
    <HoverCard
      onOpenChange={open => {
        setLoading(true);
        if (open) setTimeout(() => setLoading(false), 400);
      }}
    >
      <HoverCardTrigger
        render={<TextLink href="/hover-card">Ada Hartley</TextLink>}
      />
      <HoverCardContent loading={loading}>
        <ContactPreview />
      </HoverCardContent>
    </HoverCard>
  );
}

Keyboard

The keys it answers to. Tab moves between components, arrows move within them.

KeysWhat they do
TabFrom the link, moves into the open card; out of the card, moves on past the link and closes it.
Shift + TabFrom the card, returns to the link.
EnterFollows the link.
EscapeCloses the card and leaves focus on the link.