Stat cards

A row of cards for numbers, progress and status.

Updated

Default

Pages

Published

1,248

Storage

6.2 of 10 GB

Status

All systems normal


<div class="grid gap-4 sm:grid-cols-3">
	{ui card, title: 'Pages', description: 'Published'}
		<p class="text-3xl font-semibold">1,248</p>
	{/ui}
	{ui card, title: 'Storage', description: '6.2 of 10 GB'}
		{ui progress, value: 62, label: 'Storage used' /}
	{/ui}
	{ui card, title: 'Status'}
		<p class="flex items-center gap-2">
			{ui status, class: 'bg-success' /}
			All systems normal
		</p>
	{/ui}
</div>

A grid wraps plain cards. The number is a styled paragraph, the progress and status elements go in the body as they are.

With trends

Visitors

Last 7 days

12,480

+8%

Signups

Last 7 days

214

-3%

Bounce rate

Last 7 days

41%

-2%

<div class="grid gap-4 sm:grid-cols-3">
	{ui card, title: 'Visitors', description: 'Last 7 days'}
		<div class="flex items-center justify-between">
			<p class="text-3xl font-semibold">12,480</p>
			{ui badge, title: '+8%', class: 'bg-success' /}
		</div>
	{/ui}
	{ui card, title: 'Signups', description: 'Last 7 days'}
		<div class="flex items-center justify-between">
			<p class="text-3xl font-semibold">214</p>
			{ui badge, title: '-3%', class: 'bg-destructive' /}
		</div>
	{/ui}
	{ui card, title: 'Bounce rate', description: 'Last 7 days'}
		<div class="flex items-center justify-between">
			<p class="text-3xl font-semibold">41%</p>
			{ui badge, title: '-2%', class: 'bg-success' /}
		</div>
	{/ui}
</div>

A badge beside the number carries the change. bg-success and bg-destructive colour it by whether the move is good or bad, which is not always up or down: the falling bounce rate in the third card is good news. bg-secondary fits a number that has not really moved.