Skip to content

shadcn.io is an independent project built on shadcn/ui

Growth Stats Hover Card for React

A chip showing $12,543 and a 12.5% rise opens the current amount, the previous amount, and the change.

The chip shows $12,543, an up arrow, and 12.5%. The card is titled Revenue Growth and lists Current $12,543, Previous $11,156, and Change +$1,387.

Put it in a table or a header when a rate needs the numbers behind it. On touch, use a Popover. In React, Base UI also opens the card on focus, and Escape closes it.

Preview

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.

Anatomy

Hover Card anatomy: trigger, positioner, arrow, content

Usage

<HoverCard>
  <HoverCardTrigger
    closeDelay={100}
    delay={10}
    render={
      <button
        className="flex items-center gap-2 rounded-md border px-3 py-1.5 text-sm hover:bg-accent"
        type="button"
      />
    }
  >
    <span className="font-semibold">$12,543</span>
    <span className="flex items-center gap-1 text-success text-xs">
      <ArrowUpIcon aria-hidden="true" className="size-3" />
      12.5%
    </span>
  </HoverCardTrigger>
  <HoverCardContent className="max-w-full">
    <div className="flex flex-col gap-3">
      <div>
        <h4 className="font-semibold text-sm">Revenue Growth</h4>
        <p className="text-muted-foreground text-xs">vs. previous period</p>
      </div>
      <div className="flex flex-col gap-2 text-sm">
        <div className="flex justify-between">
          <span className="text-muted-foreground">Current:</span>
          <span className="font-medium">$12,543</span>
        </div>
        <div className="flex justify-between">
          <span className="text-muted-foreground">Previous:</span>
          <span className="font-medium">$11,156</span>
{/* The rest of the file is under Installation. */}

FAQ

What is in the card?

Revenue Growth, vs. previous period, then Current $12,543, Previous $11,156 and Change +$1,387 in text-success.

How is the growth chip made the trigger?

HoverCardTrigger takes the growth chip through render, a button with its classes.

How is the rate shown in the chip?

An up arrow and 12.5% in text-success. For a fall, use a down arrow and text-destructive.

How wide is the card?

The default hover card width. Set a width class such as w-80 on the card to fit longer content.

How do I change how fast the card opens and closes?

The card opens a moment after the pointer rests on the trigger and stays up long enough for the pointer to move into it. Both delays are in milliseconds. The demo sets delay 10 and closeDelay 100 on HoverCardTrigger. side and align on HoverCardContent place it.

Does the card open from the keyboard and on touch screens?

Focusing the chip opens the card, moving focus away or pressing Escape closes it. Touch screens have no hover, so keep what matters reachable elsewhere, or use a Popover when the card has to open on a tap.

API Reference

Hover Card

No extra props in this demo. The rest is on the Hover Card page.