Skip to content

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

Growth Stats Hover Card for Solid

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

UI library: Ark UI

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 Solid, Ark UI also opens the card on focus, and Escape closes it.

Preview

Preview width

Installation

MCP · Pro
Make your AI a shadcn expert
Your agent installs components, builds pages and restyles your app from one prompt, in Claude Code, Cursor or VS Code.
Part of Pro

Anatomy

Hover Card anatomy: trigger, positioner, arrow, content

Usage

<HoverCard>
    <HoverCardTrigger asChild={props => <button {...props({
    "class": "flex items-center gap-2 rounded-md border px-3 py-1.5 text-sm hover:bg-accent"
  })} type="button">
        <span class="font-semibold">$12,543</span>
        <span class="flex items-center gap-1 text-success text-xs">
          <ArrowUpIcon aria-hidden="true" class="size-3" />
          12.5%
        </span>
      </button>} />
    <HoverCardContent>
      <div class="flex flex-col gap-3">
        <div>
          <h4 class="font-semibold text-sm">Revenue Growth</h4>
          <p class="text-muted-foreground text-xs">vs. previous period</p>
        </div>
        <div class="flex flex-col gap-2 text-sm">
          <div class="flex justify-between">
            <span class="text-muted-foreground">Current:</span>
            <span class="font-medium">$12,543</span>
          </div>
          <div class="flex justify-between">
            <span class="text-muted-foreground">Previous:</span>
            <span class="font-medium">$11,156</span>
          </div>
          <div class="flex justify-between">
            <span class="text-muted-foreground">Change:</span>
            <span class="font-medium text-success">+$1,387</span>
          </div>
        </div>
      </div>
{/* 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 renders the growth chip through its asChild function.

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 and props. The rest is on the Hover Card page.