Skip to content

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

User Stats Hover Card for Svelte

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

UI library: Ark UI

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 Svelte, Ark UI does not track live users. The counts are sample text.

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>{#snippet asChild(props)}<button {...props({ class: "flex items-center gap-2 rounded-lg border bg-card p-4 text-start hover:bg-accent", type: "button" })}><UsersIcon aria-hidden="true" class="size-5 text-info" /><div><div class="font-bold text-2xl">8,432</div><div class="text-muted-foreground text-sm">Active Users</div></div></button>{/snippet}</HoverCardTrigger><HoverCardContent class="w-72"><div class="flex flex-col gap-3"><h4 class="font-semibold text-sm">User Activity</h4><div class="grid grid-cols-2 gap-4"><div><div class="font-bold text-xl">8,432</div><div class="text-muted-foreground text-xs">Active</div></div><div><div class="font-bold text-xl">2,156</div><div class="text-muted-foreground text-xs">New Today</div></div></div><Separator /><div class="flex flex-col gap-2 text-sm"><div class="flex justify-between"><span class="text-muted-foreground">Online Now:</span><span class="font-medium">1,234</span></div><div class="flex justify-between"><span class="text-muted-foreground">Peak Today:</span><span class="font-medium">3,421</span></div></div></div></HoverCardContent></HoverCard>

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 renders the stat tile through its asChild snippet.

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

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

Separator

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