Skip to main content
Location: sabo/src/components/dashboard/section-cards.tsx

When to use

  • Organize dashboard content into visually distinct sections.

Usage

import { Badge } from "@/components/ui/badge";
import { Card, CardAction, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card";
import { IconTrendingUp } from "@tabler/icons-react";

export function SectionCards() {
  return (
    <div className="grid grid-cols-1 gap-4 px-4 lg:px-6 @xl/main:grid-cols-2 @5xl/main:grid-cols-4">
      <Card className="@container/card">
        <CardHeader>
          <CardDescription>Total Revenue</CardDescription>
          <CardTitle className="text-2xl font-semibold tabular-nums @[250px]/card:text-3xl">
            $1,250.00
          </CardTitle>
          <CardAction>
            <Badge variant="outline">
              <IconTrendingUp />
              +12.5%
            </Badge>
          </CardAction>
        </CardHeader>
        <CardFooter className="flex-col items-start gap-1.5 text-sm">
          <div className="line-clamp-1 flex gap-2 font-medium">
            Trending up this month <IconTrendingUp className="size-4" />
          </div>
          <div className="text-muted-foreground">Visitors for the last 6 months</div>
        </CardFooter>
      </Card>
      {/* ... more cards */}
    </div>
  );
}

Styling tip

  • Maintain consistent spacing and headings; prefer grid utilities for responsive columns.

Key features

  • Container queries: Uses @container/card to adjust typography based on card width
  • Responsive grid: Adapts from 1 column → 2 columns → 4 columns based on viewport
  • CardAction: Badge positioned in top-right for metrics/trends
  • CardFooter: Additional context or trend descriptions

Steps

1

Choose layout

The component uses responsive grid with container queries: grid-cols-1 @xl/main:grid-cols-2 @5xl/main:grid-cols-4.
Container queries (@container) allow cards to adjust typography based on their own width, not just viewport.
2

Compose metric cards

Each card uses CardHeader (metric label + value + badge), and CardFooter (trend description).
<Card className="@container/card">
  <CardHeader>
    <CardDescription>Metric Label</CardDescription>
    <CardTitle className="text-2xl @[250px]/card:text-3xl">Value</CardTitle>
    <CardAction><Badge>+12%</Badge></CardAction>
  </CardHeader>
  <CardFooter>Trend description</CardFooter>
</Card>
3

Customize metrics

Replace static values with data from your API or Supabase. Use Tabler icons (@tabler/icons-react) for trend indicators.