Skip to content

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

Growth Stats Hover Card for Ark UI

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, Ark 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 asChild>
    <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>
    </button>
  </HoverCardTrigger>
  <HoverCardContent>
    <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>
        </div>
        <div className="flex justify-between">
          <span className="text-muted-foreground">Change:</span>
          <span className="font-medium text-success">+$1,387</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 asChild, and the demo passes the growth chip, a button.

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. Set openDelay and closeDelay on HoverCard; they default to 10 and 100. positioning picks another side than the bottom.

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

Sets asChild. The rest is on the Hover Card page.