DashboardCharts

The DashboardCharts family provides four ready-made chart and metric components for admin dashboards. All components are pure — they accept data and field-name props and render via Recharts inside a shadcn <Card> shell. Each component supports a loading skeleton state.

Installation

pnpm dlx shadcn@latest add @shadmin/dashboard-charts

<MetricCard>

Displays a single KPI: label, value, optional delta indicator, and optional icon.

import { MetricCard } from "@/components/admin";
import { DollarSignIcon } from "lucide-react";
 
<MetricCard
  label="Revenue"
  value={12500}
  delta={0.12}
  format={(v) => `$${v.toLocaleString()}`}
  icon={DollarSignIcon}
/>;

The delta sign determines color: positive values use emerald, negative values use rose, zero uses muted.

Props

PropRequiredTypeDefaultDescription
labelRequiredstring-Small uppercase label above the value.
valueRequirednumber | string-Main displayed value.
deltaOptionalnumber-Fractional change (e.g., 0.12 = +12%). Adds arrow + colored percentage.
formatOptional(value: number) => ReactNode-Custom formatter applied when value is a number.
iconOptionalComponentType<{ className? }>-Lucide or any icon component rendered in the top-right.
loadingOptionalbooleanfalseRender skeleton instead of content.
classNameOptionalstring-Forwarded to the outer <Card>.

<TrendChart>

A line chart for time-series data.

import { TrendChart } from "@/components/admin";
 
<TrendChart
  data={[
    { date: "2026-01", revenue: 1000 },
    { date: "2026-02", revenue: 1500 },
    { date: "2026-03", revenue: 1200 },
  ]}
  xField="date"
  yField="revenue"
  title="Monthly Revenue"
  height={220}
  color="hsl(217 91% 60%)"
/>;

Props

PropRequiredTypeDefaultDescription
dataRequiredArray<Record<string, unknown>>-Data array.
xFieldRequiredstring-Key for the X axis.
yFieldRequiredstring-Key for the Y axis / line value.
titleOptionalReactNode-Card title rendered in the header.
colorOptionalstringvar(--primary)CSS color for the line stroke.
heightOptionalnumber200Card content height in pixels.
loadingOptionalbooleanfalseRender skeleton instead of chart.
classNameOptionalstring-Forwarded to the outer <Card>.

<BarChart>

A vertical bar chart for categorical comparisons.

import { BarChart } from "@/components/admin";
 
<BarChart
  data={[
    { category: "Electronics", count: 42 },
    { category: "Clothing", count: 28 },
  ]}
  xField="category"
  yField="count"
  title="Orders by Category"
  height={220}
/>;

Props

PropRequiredTypeDefaultDescription
dataRequiredArray<Record<string, unknown>>-Data array.
xFieldRequiredstring-Key for the X axis categories.
yFieldRequiredstring-Key for bar height values.
titleOptionalReactNode-Card title rendered in the header.
colorOptionalstringvar(--primary)CSS fill color for bars.
heightOptionalnumber200Card content height in pixels.
loadingOptionalbooleanfalseRender skeleton instead of chart.
classNameOptionalstring-Forwarded to the outer <Card>.

<DonutChart>

A donut/pie chart for part-to-whole relationships.

import { DonutChart } from "@/components/admin";
 
<DonutChart
  data={[
    { label: "Open", value: 30 },
    { label: "Closed", value: 70 },
    { label: "Pending", value: 15 },
  ]}
  labelField="label"
  valueField="value"
  title="Ticket Status"
  height={220}
/>;

Props

PropRequiredTypeDefaultDescription
dataRequiredArray<Record<string, unknown>>-Data array.
labelFieldRequiredstring-Key used as the segment name (shown in tooltip).
valueFieldRequiredstring-Key for segment numeric value.
titleOptionalReactNode-Card title rendered in the header.
colorsOptionalstring[]5 CSS variable colorsArray of CSS color strings, cycled by index.
heightOptionalnumber200Card content height in pixels.
loadingOptionalbooleanfalseRender skeleton instead of chart.
classNameOptionalstring-Forwarded to the outer <Card>.

loading

All four components accept a loading prop. When true, a skeleton placeholder is rendered instead of the chart content. This is useful while data is being fetched.

<MetricCard label="Revenue" value={0} loading />
<TrendChart data={[]} xField="date" yField="value" loading />

Colors

TrendChart and BarChart default to var(--primary), which follows the active theme. Pass any CSS color string to override:

<TrendChart color="hsl(142 76% 36%)" ... />
<BarChart color="#6366f1" ... />

DonutChart defaults to five --chart-* CSS variables (falling back to hardcoded hsl values if the variables are not defined), cycling for segments beyond the fifth.