When adding a new dashboard metric card to this Next.js 15 dashboard application:
- •
Choose the appropriate card component based on the metric type:
- •Use
DashboardCardfor basic metrics with custom content - •Use
DashboardStatCardfor statistics with trend indicators (percentage changes) - •Use
DashboardChartCardfor metrics that include embedded charts
- •Use
- •
Import the required components:
tsximport { DashboardCard, DashboardStatCard } from "@/components/DashboardCards"; import { IconName } from "lucide-react"; // For stat cards - •
Add the card data to the appropriate data array:
- •For stat cards in
DashboardCharts.tsx, add to thestatsarray:tsx{ title: "Metric Name", value: "Value with units", change: "+X.X%", changeType: "positive" | "negative", icon: IconName, } - •For custom cards, directly add JSX in the component
- •For stat cards in
- •
Follow styling conventions:
- •Use CSS custom properties for colors:
hsl(var(--border)),hsl(var(--muted-foreground)) - •Ensure responsive design with mobile-first approach
- •Use
cn()utility from@/lib/utilsfor conditional classes
- •Use CSS custom properties for colors:
- •
Maintain the grid layout:
- •Stat cards use:
grid grid-cols-1 md:grid-cols-2 xl:grid-cols-4 gap-6 - •Ensure new cards fit the existing responsive grid structure
- •Stat cards use:
- •
Type safety:
- •Define TypeScript interfaces for custom card props
- •Use
as constfor union types likechangeType
Examples
Add a revenue stat card
tsx
// In DashboardCharts.tsx, add to stats array:
{
title: "Monthly Revenue",
value: "$12,345",
change: "+15.3%",
changeType: "positive" as const,
icon: DollarSign,
}
Add a custom metric card
tsx
<DashboardCard title="Custom Metric" value="142">
<MiniLineChart data={chartData} />
</DashboardCard>
Related Files
- •
src/components/DashboardCards.tsx - •
src/components/DashboardCharts.tsx - •
src/lib/charts.tsx
Related Skills
- •
add-chart - •
add-shadcn-component