Skip to content

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

Simple Stats Hover Card for Solid

A Total Views tile showing 12,543 opens today, this week, and this month on a small breakdown card.

UI library: Ark UI

The tile shows an up-trend icon, 12,543, and Total Views. The card is titled View Statistics and lists Today 342, This Week 2,156, and This Month 8,932.

Reach for it when a total needs three periods and nothing more. On a touch screen, open the breakdown in a Popover. In Solid, Ark UI does not add up the views.

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-lg border bg-card p-4 text-start hover:bg-accent"
  })} type="button">
        <TrendingUpIcon aria-hidden="true" class="size-5 text-success" />
        <div>
          <div class="font-bold text-2xl">12,543</div>
          <div class="text-muted-foreground text-sm">Total Views</div>
        </div>
      </button>} />
    <HoverCardContent>
      <div class="flex flex-col gap-2">
        <h4 class="font-semibold text-sm">View Statistics</h4>
        <div class="flex flex-col gap-1 text-muted-foreground text-sm">
          <div class="flex justify-between">
            <span>Today:</span>
            <span class="font-medium text-foreground">342</span>
          </div>
          <div class="flex justify-between">
            <span>This Week:</span>
            <span class="font-medium text-foreground">2,156</span>
          </div>
          <div class="flex justify-between">
            <span>This Month:</span>
            <span class="font-medium text-foreground">8,932</span>
          </div>
        </div>
      </div>
    </HoverCardContent>
  </HoverCard>

FAQ

What is in the card?

View Statistics and three rows: Today 342, This Week 2,156 and This Month 8,932, with the numbers in the foreground color.

How is the stat tile made the trigger?

HoverCardTrigger renders the stat tile through its asChild function.

How is the tile styled?

A bordered bg-card button with a trending-up icon in text-success, the number in large bold text and the label in muted text. text-start keeps the text aligned in both directions.

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 tile 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.