Skip to content

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

User Stats Hover Card for Ark UI

An Active Users tile showing 8,432 opens active and new counts, plus 1,234 online and a peak of 3,421.

The tile shows a people icon, 8,432, and Active Users. The card is titled User Activity, with 8,432 active, 2,156 new today, 1,234 online now, and a peak of 3,421.

Use it on an admin dashboard when the headline needs a breakdown. A tap should open a Popover. In React, Ark UI does not track live users. The counts are sample text.

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-lg border bg-card p-4 text-start hover:bg-accent"
      type="button"
    >
      <UsersIcon aria-hidden="true" className="size-5 text-info" />
      <div>
        <div className="font-bold text-2xl">8,432</div>
        <div className="text-muted-foreground text-sm">Active Users</div>
      </div>
    </button>
  </HoverCardTrigger>
  <HoverCardContent className="w-72">
    <div className="flex flex-col gap-3">
      <h4 className="font-semibold text-sm">User Activity</h4>
      <div className="grid grid-cols-2 gap-4">
        <div>
          <div className="font-bold text-xl">8,432</div>
          <div className="text-muted-foreground text-xs">Active</div>
        </div>
        <div>
          <div className="font-bold text-xl">2,156</div>
          <div className="text-muted-foreground text-xs">New Today</div>
        </div>
      </div>
      <Separator />
      <div className="flex flex-col gap-2 text-sm">
        <div className="flex justify-between">
          <span className="text-muted-foreground">Online Now:</span>
          <span className="font-medium">1,234</span>
{/* The rest of the file is under Installation. */}

FAQ

What is in the card?

8,432 Active and 2,156 New Today in a two-column grid, a separator, then Online Now 1,234 and Peak Today 3,421.

How is the stat tile made the trigger?

HoverCardTrigger takes asChild, and the demo passes the stat tile, a button.

Why is the users icon blue?

It uses text-info, the informational token, since the number is neither good nor bad. It follows the theme in light and dark mode.

How wide is the card?

w-72 on the card, for the extra content. The class is on HoverCardContent.

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

Separator

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