Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Hover Card examples · Stats

Simple Stats Hover Card for React

A views tile that opens the views for today, this week and this month.

Framework
UI library

A Total Views tile opens a short breakdown by period: today, this week and this month. The simplest stats card, a starting point for the others.

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.

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 takes the stat tile through render, a button with its classes.

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. The demo sets delay 10 and closeDelay 100 on HoverCardTrigger. side and align on HoverCardContent place it.

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.