Charts
Dashboard chart cards built on the shadcn/ui chart and Recharts: area, stacked bar, line, donut, radial and sparkline charts, each with a title, the key number, a tooltip and a footer note. Colors come only from the theme's chart variables, so every theme recolors them.
7 examples below. They wear whichever DressCode theme you install.
Area chart with time range
Two gradient areas, invoiced and collected, with a 7 day, 30 day or 3 month range select.
npx shadcn@latest add https://dresscodeui.com/r/dresscode/charts-area-interactive.json"use client"
// Payments over time: what was invoiced and what was collected each day, as two gradient areas. The
// range select (7 days, 30 days, 3 months) swaps the data, the totals and the change against the
// period before.
import * as React from "react"
import { TrendingDown, TrendingUp } from "lucide-react"
import { Area, AreaChart, CartesianGrid, XAxis, YAxis } from "recharts"
import { Badge } from "@/components/ui/badge"
import { Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card"
import { type ChartConfig, ChartContainer, ChartTooltip, ChartTooltipContent } from "@/components/ui/chart"
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
const chartConfig = {
invoiced: { label: "Invoiced", color: "var(--chart-2)" },
collected: { label: "Collected", color: "var(--chart-1)" },
} satisfies ChartConfig
const RANGES = [
{ value: "7d", label: "Last 7 days", days: 7 },
{ value: "30d", label: "Last 30 days", days: 30 },
{ value: "90d", label: "Last 3 months", days: 90 },
] as const
type Range = (typeof RANGES)[number]["value"]
// Sample data: 180 days ending Nov 24, 2026, so every range has a period before it to compare with.
// Replace it with your own rows of { date, invoiced, collected }.
const DATA = (() => {
let seed = 11
const rand = () => ((seed = (seed * 16807) % 2147483647) - 1) / 2147483646
const end = Date.UTC(2026, 10, 24)
return Array.from({ length: 180 }, (_, i) => {
const t = end - (179 - i) * 86_400_000
const day = new Date(t).getUTCDay()
const weekend = day === 0 || day === 6
const growth = (1 + i / 420) * (1 + 0.12 * Math.sin(i / 7))
const round = (n: number) => Math.round(n / 10) * 10
return {
date: new Date(t).toISOString().slice(0, 10),
invoiced: round((weekend ? 1120 : 1720) * growth * (0.88 + rand() * 0.24)),
collected: round((weekend ? 980 : 1530) * growth * (0.86 + rand() * 0.28)),
}
})
})()
const usd = new Intl.NumberFormat("en-US", { style: "currency", currency: "USD", maximumFractionDigits: 0 })
const usdShort = new Intl.NumberFormat("en-US", { style: "currency", currency: "USD", notation: "compact", maximumFractionDigits: 1 })
const dayShort = new Intl.DateTimeFormat("en-US", { month: "short", day: "numeric", timeZone: "UTC" })
const dayLong = new Intl.DateTimeFormat("en-US", { weekday: "short", month: "short", day: "numeric", timeZone: "UTC" })
const asDate = (iso: string) => new Date(`${iso}T00:00:00Z`)
const sum = (rows: typeof DATA, key: "invoiced" | "collected") => rows.reduce((n, r) => n + r[key], 0)
export default function ChartsAreaInteractive() {
const [range, setRange] = React.useState<Range>("30d")
const id = React.useId().replace(/:/g, "")
const days = RANGES.find((r) => r.value === range)!.days
const rows = DATA.slice(-days)
const before = DATA.slice(-2 * days, -days)
const collected = sum(rows, "collected")
const invoiced = sum(rows, "invoiced")
const change = ((collected - sum(before, "collected")) / sum(before, "collected")) * 100
const invoicedChange = ((invoiced - sum(before, "invoiced")) / sum(before, "invoiced")) * 100
const rate = Math.round((collected / invoiced) * 100)
const up = change >= 0
const period = days === 90 ? "3 months" : `${days} days`
return (
<Card className="w-full max-w-4xl">
<CardHeader>
<CardTitle>Payments</CardTitle>
<CardDescription>What you invoiced and what came in, day by day</CardDescription>
<CardAction>
<Select items={RANGES.map(({ value, label }) => ({ value, label }))} value={range} onValueChange={(v) => v && setRange(v as Range)}>
<SelectTrigger size="sm" aria-label="Time range" className="w-[136px]">
<SelectValue />
</SelectTrigger>
<SelectContent align="end">
{RANGES.map((r) => (
<SelectItem key={r.value} value={r.value}>
{r.label}
</SelectItem>
))}
</SelectContent>
</Select>
</CardAction>
</CardHeader>
<CardContent className="grid gap-4">
<dl className="flex flex-wrap gap-x-10 gap-y-3" aria-live="polite">
<div>
<dt className="flex items-center gap-1.5 text-xs text-muted-foreground">
<span className="size-2 rounded-[2px] bg-(--chart-1)" aria-hidden />
Collected
</dt>
<dd className="mt-1 flex items-center gap-2">
<span className="text-2xl font-semibold tracking-tight tabular-nums">{usd.format(collected)}</span>
<Badge variant={up ? "secondary" : "destructive"}>
{up ? <TrendingUp aria-hidden /> : <TrendingDown aria-hidden />}
<span className="sr-only">{up ? "Up" : "Down"}</span>
{Math.abs(change).toFixed(1)}%
</Badge>
</dd>
</div>
<div>
<dt className="flex items-center gap-1.5 text-xs text-muted-foreground">
<span className="size-2 rounded-[2px] bg-(--chart-2)" aria-hidden />
Invoiced
</dt>
<dd className="mt-1 flex items-baseline gap-2">
<span className="text-2xl font-semibold tracking-tight tabular-nums">{usd.format(invoiced)}</span>
<span className="text-xs text-muted-foreground tabular-nums">
{invoicedChange >= 0 ? "+" : "−"}
{Math.abs(invoicedChange).toFixed(1)}%
</span>
</dd>
</div>
</dl>
<ChartContainer config={chartConfig} className="aspect-auto h-[240px] w-full [&_.recharts-cartesian-axis-tick-value]:fill-muted-foreground rounded-md has-[.recharts-surface:focus-visible]:ring-3 has-[.recharts-surface:focus-visible]:ring-ring/50 [&_g[tabindex]]:outline-hidden">
<AreaChart data={rows} margin={{ top: 8, right: 4, left: 0, bottom: 0 }}>
<defs>
{(["invoiced", "collected"] as const).map((key) => (
<linearGradient key={key} id={`${id}-${key}`} x1="0" y1="0" x2="0" y2="1">
<stop offset="0%" stopColor={`var(--color-${key})`} stopOpacity={key === "collected" ? 0.42 : 0.55} />
<stop offset="100%" stopColor={`var(--color-${key})`} stopOpacity={0.03} />
</linearGradient>
))}
</defs>
<CartesianGrid vertical={false} />
<XAxis
dataKey="date"
tickLine={false}
axisLine={false}
tickMargin={8}
minTickGap={28}
tickFormatter={(v: string) => dayShort.format(asDate(v))}
/>
<YAxis tickLine={false} axisLine={false} width={44} tickMargin={4} tickCount={4} tickFormatter={(v: number) => usdShort.format(v)} />
<ChartTooltip
content={
<ChartTooltipContent
className="min-w-44"
labelFormatter={(v) => dayLong.format(asDate(String(v)))}
formatter={(value, name) => (
<div className="flex w-full items-center gap-2">
<span className="size-2.5 shrink-0 rounded-[2px]" style={{ background: `var(--color-${name})` }} />
<span className="text-muted-foreground">{chartConfig[name as keyof typeof chartConfig]?.label}</span>
<span className="ml-auto font-medium text-foreground tabular-nums">{usd.format(Number(value))}</span>
</div>
)}
/>
}
/>
<Area
dataKey="invoiced"
type="monotone"
stroke="var(--color-invoiced)"
strokeWidth={2}
fill={`url(#${id}-invoiced)`}
activeDot={{ r: 4, strokeWidth: 2, stroke: "var(--card)" }}
/>
<Area
dataKey="collected"
type="monotone"
stroke="var(--color-collected)"
strokeWidth={2}
fill={`url(#${id}-collected)`}
activeDot={{ r: 4, strokeWidth: 2, stroke: "var(--card)" }}
/>
</AreaChart>
</ChartContainer>
</CardContent>
<CardFooter className="flex-col items-start gap-1 text-sm sm:flex-row sm:items-center sm:justify-between">
<p className="flex items-center gap-1.5 font-medium">
Collected {Math.abs(change).toFixed(1)}% {up ? "more" : "less"} than the {period} before
{up ? <TrendingUp className="size-4" aria-hidden /> : <TrendingDown className="size-4" aria-hidden />}
</p>
<p className="text-muted-foreground">
{rate}% of the invoiced amount came in · {dayShort.format(asDate(rows[0].date))} to {dayShort.format(asDate(rows[rows.length - 1].date))}
</p>
</CardFooter>
</Card>
)
}Stacked bars
Billing by month stacked by kind of work, with a legend that filters and a tooltip with totals.
npx shadcn@latest add https://dresscodeui.com/r/dresscode/charts-bar-stacked.json"use client"
// Billing by month, stacked by kind of work. The legend doubles as a filter (click a kind to hide it),
// and the tooltip lists each kind with the month's total under it.
import * as React from "react"
import { TrendingUp } from "lucide-react"
import { Bar, BarChart, CartesianGrid, XAxis, YAxis } from "recharts"
import { Badge } from "@/components/ui/badge"
import { Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card"
import { type ChartConfig, ChartContainer, ChartTooltip, ChartTooltipContent } from "@/components/ui/chart"
import { cn } from "@/lib/utils"
// One hue in three strengths, mixed toward the card, so the stack reads in any theme and either mode.
const chartConfig = {
retainers: { label: "Retainers", color: "var(--chart-1)" },
projects: { label: "Projects", color: "color-mix(in oklab, var(--chart-1) 62%, var(--card))" },
expenses: { label: "Rebilled expenses", color: "color-mix(in oklab, var(--chart-1) 34%, var(--card))" },
} satisfies ChartConfig
type Kind = keyof typeof chartConfig
const KINDS = Object.keys(chartConfig) as Kind[]
// Sample data: the last 12 months, in dollars.
const DATA = [
{ month: "2025-12", retainers: 18400, projects: 9200, expenses: 1650 },
{ month: "2026-01", retainers: 18400, projects: 6800, expenses: 1240 },
{ month: "2026-02", retainers: 19600, projects: 8900, expenses: 1580 },
{ month: "2026-03", retainers: 19600, projects: 12300, expenses: 2210 },
{ month: "2026-04", retainers: 20800, projects: 10700, expenses: 1930 },
{ month: "2026-05", retainers: 20800, projects: 13900, expenses: 2480 },
{ month: "2026-06", retainers: 22000, projects: 11600, expenses: 1870 },
{ month: "2026-07", retainers: 22000, projects: 9400, expenses: 1520 },
{ month: "2026-08", retainers: 22000, projects: 10200, expenses: 1760 },
{ month: "2026-09", retainers: 23400, projects: 14800, expenses: 2640 },
{ month: "2026-10", retainers: 23400, projects: 16200, expenses: 2910 },
{ month: "2026-11", retainers: 24600, projects: 15100, expenses: 2380 },
]
const PRIOR_YEAR_TOTAL = 336_900
const usd = new Intl.NumberFormat("en-US", { style: "currency", currency: "USD", maximumFractionDigits: 0 })
const usdShort = new Intl.NumberFormat("en-US", { style: "currency", currency: "USD", notation: "compact", maximumFractionDigits: 0 })
const monthShort = new Intl.DateTimeFormat("en-US", { month: "short", timeZone: "UTC" })
const monthLong = new Intl.DateTimeFormat("en-US", { month: "long", year: "numeric", timeZone: "UTC" })
const asDate = (ym: string) => new Date(`${ym}-01T00:00:00Z`)
export default function ChartsBarStacked() {
const [shown, setShown] = React.useState<Record<Kind, boolean>>({ retainers: true, projects: true, expenses: true })
const visible = KINDS.filter((k) => shown[k])
const top = visible[visible.length - 1]
const total = DATA.reduce((n, row) => n + visible.reduce((m, k) => m + row[k], 0), 0)
const all = DATA.reduce((n, row) => n + KINDS.reduce((m, k) => m + row[k], 0), 0)
const growth = ((all - PRIOR_YEAR_TOTAL) / PRIOR_YEAR_TOTAL) * 100
const share = (k: Kind) => Math.round((DATA.reduce((n, r) => n + r[k], 0) / all) * 100)
const toggle = (k: Kind) =>
setShown((s) => (s[k] && visible.length === 1 ? s : { ...s, [k]: !s[k] }))
return (
<Card className="w-full max-w-3xl">
<CardHeader>
<CardTitle>Billed by kind of work</CardTitle>
<CardDescription>December 2025 to November 2026</CardDescription>
<CardAction className="text-right">
<p className="text-2xl font-semibold tracking-tight tabular-nums" aria-live="polite">
{usd.format(total)}
</p>
<p className="mt-0.5 flex items-center justify-end gap-1.5 text-xs text-muted-foreground">
{visible.length === KINDS.length ? "All work" : visible.map((k) => chartConfig[k].label).join(" and ")}
</p>
</CardAction>
</CardHeader>
<CardContent className="grid gap-4">
<div role="group" aria-label="Kinds of work shown" className="flex flex-wrap gap-1.5">
{KINDS.map((k) => (
<button
key={k}
type="button"
aria-pressed={shown[k]}
onClick={() => toggle(k)}
className={cn(
"inline-flex h-7 items-center gap-2 rounded-md border border-border px-2.5 text-xs font-medium transition-colors outline-none hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/50",
!shown[k] && "text-muted-foreground"
)}
>
<span
className={cn("size-2.5 rounded-[3px] ring-1 ring-foreground/15 ring-inset", !shown[k] && "opacity-30")}
style={{ background: chartConfig[k].color }}
aria-hidden
/>
<span className={cn(!shown[k] && "line-through")}>{chartConfig[k].label}</span>
<span className="text-muted-foreground tabular-nums">{share(k)}%</span>
</button>
))}
</div>
<ChartContainer config={chartConfig} className="aspect-auto h-[260px] w-full [&_.recharts-cartesian-axis-tick-value]:fill-muted-foreground rounded-md has-[.recharts-surface:focus-visible]:ring-3 has-[.recharts-surface:focus-visible]:ring-ring/50 [&_g[tabindex]]:outline-hidden">
<BarChart data={DATA} margin={{ top: 4, right: 0, left: 0, bottom: 0 }} barCategoryGap="22%">
<CartesianGrid vertical={false} />
<XAxis dataKey="month" tickLine={false} axisLine={false} tickMargin={8} tickFormatter={(v: string) => monthShort.format(asDate(v))} />
<YAxis tickLine={false} axisLine={false} width={44} tickMargin={4} tickCount={4} tickFormatter={(v: number) => usdShort.format(v)} />
<ChartTooltip
cursor={{ fill: "var(--muted)", opacity: 0.6 }}
content={
<ChartTooltipContent
className="min-w-48"
labelFormatter={(_, payload) => monthLong.format(asDate(String(payload?.[0]?.payload?.month)))}
formatter={(value, name, item, index) => {
const key = name as Kind
const last = index === visible.length - 1
const row = item.payload as (typeof DATA)[number]
const monthTotal = visible.reduce((n, k) => n + row[k], 0)
return (
<>
<div className="flex w-full items-center gap-2">
<span className="size-2.5 shrink-0 rounded-[2px]" style={{ background: `var(--color-${key})` }} />
<span className="text-muted-foreground">{chartConfig[key]?.label}</span>
<span className="ml-auto font-medium text-foreground tabular-nums">{usd.format(Number(value))}</span>
</div>
{last ? (
<div className="mt-0.5 flex w-full items-center border-t border-border pt-1.5 font-medium text-foreground">
Total
<span className="ml-auto tabular-nums">{usd.format(monthTotal)}</span>
</div>
) : null}
</>
)
}}
/>
}
/>
{KINDS.map((k) => (
<Bar
key={k}
dataKey={k}
stackId="billed"
hide={!shown[k]}
fill={`var(--color-${k})`}
radius={k === top ? [4, 4, 0, 0] : 0}
maxBarSize={40}
/>
))}
</BarChart>
</ChartContainer>
<table className="sr-only">
<caption>Billed by kind of work, per month</caption>
<thead>
<tr>
<th scope="col">Month</th>
{KINDS.map((k) => (
<th key={k} scope="col">
{chartConfig[k].label}
</th>
))}
<th scope="col">Total</th>
</tr>
</thead>
<tbody>
{DATA.map((row) => (
<tr key={row.month}>
<th scope="row">{monthLong.format(asDate(row.month))}</th>
{KINDS.map((k) => (
<td key={k}>{usd.format(row[k])}</td>
))}
<td>{usd.format(KINDS.reduce((n, k) => n + row[k], 0))}</td>
</tr>
))}
</tbody>
</table>
</CardContent>
<CardFooter className="flex-col items-start gap-1 text-sm sm:flex-row sm:items-center sm:justify-between">
<p className="flex items-center gap-2 font-medium">
<Badge variant="secondary">
<TrendingUp aria-hidden />+{growth.toFixed(1)}%
</Badge>
on the 12 months before, {usd.format(PRIOR_YEAR_TOTAL)}
</p>
<p className="text-muted-foreground">Retainers cover {share("retainers")}% of what you bill</p>
</CardFooter>
</Card>
)
}Year over year
This year against last year and a dashed target, with dots on hover and a year-to-date view.
npx shadcn@latest add https://dresscodeui.com/r/dresscode/charts-line-comparison.json"use client"
// Revenue this year against last year and the plan: two solid lines and a dashed target, with dots on
// hover. The target is drawn last so its dashes stay visible where it meets this year's line. A toggle
// switches between monthly figures and the running year-to-date total.
import * as React from "react"
import { TrendingUp } from "lucide-react"
import { CartesianGrid, Line, LineChart, XAxis, YAxis } from "recharts"
import { Badge } from "@/components/ui/badge"
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card"
import { type ChartConfig, ChartContainer, ChartTooltip, ChartTooltipContent } from "@/components/ui/chart"
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"
import { cn } from "@/lib/utils"
const chartConfig = {
thisYear: { label: "2026", color: "var(--chart-1)" },
lastYear: { label: "2025", color: "var(--chart-4)" },
target: { label: "Target", color: "var(--foreground)" },
} satisfies ChartConfig
type Series = keyof typeof chartConfig
const SERIES_ORDER: Series[] = ["thisYear", "lastYear", "target"]
// Sample data: monthly revenue in dollars. December 2026 is still open, so it has no figure yet.
const MONTHLY = [
{ month: "Jan", thisYear: 35800, lastYear: 31200, target: 36000 },
{ month: "Feb", thisYear: 34100, lastYear: 29400, target: 36500 },
{ month: "Mar", thisYear: 39700, lastYear: 34100, target: 38000 },
{ month: "Apr", thisYear: 38200, lastYear: 33300, target: 39500 },
{ month: "May", thisYear: 42900, lastYear: 36200, target: 41000 },
{ month: "Jun", thisYear: 44800, lastYear: 38400, target: 42500 },
{ month: "Jul", thisYear: 40600, lastYear: 35100, target: 44000 },
{ month: "Aug", thisYear: 43500, lastYear: 37300, target: 45500 },
{ month: "Sep", thisYear: 47900, lastYear: 40800, target: 47000 },
{ month: "Oct", thisYear: 50400, lastYear: 43200, target: 48500 },
{ month: "Nov", thisYear: 52300, lastYear: 45100, target: 50000 },
{ month: "Dec", thisYear: null, lastYear: 51600, target: 54000 },
]
type Row = { month: string; thisYear: number | null; lastYear: number; target: number }
const RUNNING: Row[] = MONTHLY.reduce<Row[]>((rows, m, i) => {
const prev = rows[i - 1]
rows.push({
month: m.month,
thisYear: m.thisYear == null ? null : (prev?.thisYear ?? 0) + m.thisYear,
lastYear: (prev?.lastYear ?? 0) + m.lastYear,
target: (prev?.target ?? 0) + m.target,
})
return rows
}, [])
// Monthly view: start the axis just under the lowest month so the gaps between the lines show.
const MONTHLY_DOMAIN: [number, number] = [
Math.floor(Math.min(...MONTHLY.flatMap((m) => [m.lastYear, m.target, m.thisYear ?? Infinity])) / 5000) * 5000,
Math.ceil(Math.max(...MONTHLY.flatMap((m) => [m.lastYear, m.target, m.thisYear ?? 0])) / 5000) * 5000,
]
const closed = MONTHLY.filter((m) => m.thisYear != null)
const ytd = (key: Series) => closed.reduce((n, m) => n + (m[key] ?? 0), 0)
const YTD = { thisYear: ytd("thisYear"), lastYear: ytd("lastYear"), target: ytd("target") }
const growth = ((YTD.thisYear - YTD.lastYear) / YTD.lastYear) * 100
const ofTarget = (YTD.thisYear / YTD.target) * 100
const monthsAhead = closed.filter((m) => (m.thisYear ?? 0) >= m.target).length
const usd = new Intl.NumberFormat("en-US", { style: "currency", currency: "USD", maximumFractionDigits: 0 })
const usdShort = new Intl.NumberFormat("en-US", { style: "currency", currency: "USD", notation: "compact", maximumFractionDigits: 0 })
const MONTH_NAMES: Record<string, string> = {
Jan: "January", Feb: "February", Mar: "March", Apr: "April", May: "May", Jun: "June",
Jul: "July", Aug: "August", Sep: "September", Oct: "October", Nov: "November", Dec: "December",
}
function LineKey({ series, dashed }: { series: Series; dashed?: boolean }) {
return (
<li className="flex items-center gap-1.5">
<svg width="18" height="8" viewBox="0 0 18 8" aria-hidden className="shrink-0 overflow-visible">
<line
x1="1"
y1="4"
x2="17"
y2="4"
stroke={chartConfig[series].color}
strokeWidth={series === "thisYear" ? 2.5 : 2}
strokeDasharray={dashed ? "4 3" : undefined}
strokeOpacity={series === "target" ? 0.7 : 1}
strokeLinecap="round"
/>
</svg>
{chartConfig[series].label}
</li>
)
}
export default function ChartsLineComparison() {
const [view, setView] = React.useState<"monthly" | "running">("monthly")
const data = view === "monthly" ? MONTHLY : RUNNING
return (
<Card className="w-full max-w-3xl">
<CardHeader>
<CardTitle>Revenue against last year</CardTitle>
<CardDescription>2026 so far, with the 2025 figures and this year's target</CardDescription>
</CardHeader>
<CardContent className="grid gap-4">
<div className="flex flex-wrap items-end justify-between gap-x-6 gap-y-3">
<div>
<p className="text-xs text-muted-foreground">Revenue, January to November</p>
<p className="mt-1 flex items-center gap-2">
<span className="text-2xl font-semibold tracking-tight tabular-nums">{usd.format(YTD.thisYear)}</span>
<Badge variant="secondary">
<TrendingUp aria-hidden />+{growth.toFixed(1)}% on 2025
</Badge>
</p>
</div>
<ToggleGroup
variant="outline"
size="sm"
spacing={0}
value={[view]}
onValueChange={(v) => v[0] && setView(v[0] as typeof view)}
aria-label="Figures shown"
>
<ToggleGroupItem value="monthly" className="px-2.5">
Monthly
</ToggleGroupItem>
<ToggleGroupItem value="running" className="px-2.5">
Year to date
</ToggleGroupItem>
</ToggleGroup>
</div>
<ul className="-mb-1 flex flex-wrap gap-x-4 gap-y-1 text-xs text-muted-foreground" aria-label="Lines">
<LineKey series="thisYear" />
<LineKey series="lastYear" />
<LineKey series="target" dashed />
</ul>
<ChartContainer config={chartConfig} className="aspect-auto h-[260px] w-full [&_.recharts-cartesian-axis-tick-value]:fill-muted-foreground rounded-md has-[.recharts-surface:focus-visible]:ring-3 has-[.recharts-surface:focus-visible]:ring-ring/50 [&_g[tabindex]]:outline-hidden">
<LineChart data={data} margin={{ top: 8, right: 8, left: 0, bottom: 0 }}>
<CartesianGrid vertical={false} />
<XAxis dataKey="month" tickLine={false} axisLine={false} tickMargin={8} />
<YAxis
tickLine={false}
axisLine={false}
width={48}
tickMargin={4}
tickCount={4}
domain={view === "monthly" ? MONTHLY_DOMAIN : [0, "auto"]}
tickFormatter={(v: number) => usdShort.format(v)}
/>
<ChartTooltip
itemSorter={(item) => SERIES_ORDER.indexOf(item.dataKey as Series)}
content={
<ChartTooltipContent
className="min-w-52"
labelFormatter={(m) => `${MONTH_NAMES[String(m)] ?? m}${view === "running" ? ", year to date" : ""}`}
formatter={(value, name, item) => {
const key = name as Series
const row = item.payload as Row
const vsLast = key === "thisYear" && row.thisYear != null ? ((row.thisYear - row.lastYear) / row.lastYear) * 100 : null
return (
<div className="flex w-full items-center gap-2">
<span
className={cn("w-3 shrink-0 border-t-2", key === "target" && "border-dashed opacity-70")}
style={{ borderColor: `var(--color-${key})` }}
/>
<span className="text-muted-foreground">{chartConfig[key]?.label}</span>
{vsLast != null ? <span className="text-muted-foreground tabular-nums">+{vsLast.toFixed(0)}%</span> : null}
<span className="ml-auto font-medium text-foreground tabular-nums">
{value == null ? "Not closed yet" : usd.format(Number(value))}
</span>
</div>
)
}}
/>
}
/>
<Line
dataKey="lastYear"
type="monotone"
stroke="var(--color-lastYear)"
strokeWidth={2}
dot={false}
activeDot={{ r: 4, fill: "var(--color-lastYear)", stroke: "var(--card)", strokeWidth: 2 }}
/>
<Line
dataKey="thisYear"
type="monotone"
stroke="var(--color-thisYear)"
strokeWidth={2.5}
dot={false}
activeDot={{ r: 5, fill: "var(--color-thisYear)", stroke: "var(--card)", strokeWidth: 2 }}
/>
<Line
dataKey="target"
type="monotone"
stroke="var(--color-target)"
strokeOpacity={0.7}
strokeWidth={1.5}
strokeDasharray="5 4"
dot={false}
isAnimationActive={false}
activeDot={{ r: 3.5, fill: "var(--color-target)", stroke: "var(--card)", strokeWidth: 2 }}
/>
</LineChart>
</ChartContainer>
</CardContent>
<CardFooter className="flex-col items-start gap-1 text-sm sm:flex-row sm:items-center sm:justify-between">
<p className="font-medium">
{ofTarget.toFixed(1)}% of the year-to-date target, {usd.format(Math.abs(YTD.thisYear - YTD.target))}{" "}
{YTD.thisYear >= YTD.target ? "ahead" : "behind"}
</p>
<p className="text-muted-foreground">
At or above target in {monthsAhead} of {closed.length} months
</p>
</CardFooter>
</Card>
)
}Donut with legend
Payment methods around the month's total, with each method's amount and share beside it.
npx shadcn@latest add https://dresscodeui.com/r/dresscode/charts-donut.json"use client"
// Payments by method: a donut with the month's total in the centre and a legend list with each method's
// amount and share. Pointing at a slice or a row (or focusing a row) puts that method in the centre.
import * as React from "react"
import { Label, Pie, PieChart, Sector } from "recharts"
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card"
import { type ChartConfig, ChartContainer } from "@/components/ui/chart"
import { cn } from "@/lib/utils"
// One hue in four strengths, mixed toward the card, so the slices read in any theme and either mode.
const chartConfig = {
cards: { label: "Card", color: "var(--chart-1)" },
transfer: { label: "Bank transfer", color: "color-mix(in oklab, var(--chart-1) 72%, var(--card))" },
debit: { label: "Direct debit", color: "color-mix(in oklab, var(--chart-1) 47%, var(--card))" },
other: { label: "Cheque and cash", color: "color-mix(in oklab, var(--chart-1) 25%, var(--card))" },
} satisfies ChartConfig
type Method = keyof typeof chartConfig
// Sample data: payments received in November 2026.
const DATA: { method: Method; amount: number; payments: number; fill: string }[] = [
{ method: "cards", amount: 58940, payments: 214, fill: "var(--color-cards)" },
{ method: "transfer", amount: 39310, payments: 61, fill: "var(--color-transfer)" },
{ method: "debit", amount: 19870, payments: 48, fill: "var(--color-debit)" },
{ method: "other", amount: 10330, payments: 9, fill: "var(--color-other)" },
]
const TOTAL = DATA.reduce((n, d) => n + d.amount, 0)
const COUNT = DATA.reduce((n, d) => n + d.payments, 0)
const usd = new Intl.NumberFormat("en-US", { style: "currency", currency: "USD", maximumFractionDigits: 0 })
const pct = (n: number) => `${((n / TOTAL) * 100).toFixed(1)}%`
export default function ChartsDonut() {
const [active, setActive] = React.useState<number | null>(null)
const focus = active == null ? null : DATA[active]
return (
<Card className="w-full max-w-2xl">
<CardHeader>
<CardTitle>Payments by method</CardTitle>
<CardDescription>How clients paid in November 2026</CardDescription>
</CardHeader>
<CardContent className="grid items-center gap-6 sm:grid-cols-[minmax(0,240px)_1fr] sm:gap-8">
<ChartContainer config={chartConfig} className="mx-auto aspect-square w-full max-w-[240px] [&_g[tabindex]]:outline-hidden" aria-hidden>
<PieChart accessibilityLayer={false}>
<Pie
data={DATA}
dataKey="amount"
nameKey="method"
startAngle={90}
endAngle={-270}
innerRadius="64%"
outerRadius="92%"
paddingAngle={1.5}
cornerRadius={3}
stroke="var(--card)"
strokeWidth={2}
rootTabIndex={-1}
onMouseEnter={(_, i) => setActive(i)}
onMouseLeave={() => setActive(null)}
shape={(props, i) => (
<Sector
{...props}
outerRadius={i === active ? props.outerRadius + 8 : props.outerRadius}
/>
)}
>
<Label
content={({ viewBox }) => {
if (!viewBox || !("cx" in viewBox)) return null
const { cx = 0, cy = 0 } = viewBox
return (
<text x={cx} y={cy} textAnchor="middle" dominantBaseline="middle">
<tspan x={cx} y={cy - 10} className="fill-foreground text-xl font-semibold tabular-nums">
{usd.format(focus ? focus.amount : TOTAL)}
</tspan>
<tspan x={cx} y={cy + 14} className="fill-muted-foreground text-xs">
{focus ? chartConfig[focus.method].label : "Collected"}
</tspan>
</text>
)
}}
/>
</Pie>
</PieChart>
</ChartContainer>
<div className="min-w-0">
<p className="sr-only" aria-live="polite">
{focus ? `${chartConfig[focus.method].label}: ${usd.format(focus.amount)}, ${pct(focus.amount)} of payments` : ""}
</p>
<ul className="grid gap-0.5" aria-label={`Payments by method, ${usd.format(TOTAL)} in total`}>
{DATA.map((d, i) => (
<li key={d.method}>
<button
type="button"
onMouseEnter={() => setActive(i)}
onMouseLeave={() => setActive(null)}
onFocus={() => setActive(i)}
onBlur={() => setActive(null)}
className={cn(
"grid w-full grid-cols-[auto_1fr_auto] items-center gap-x-3 gap-y-0.5 rounded-lg px-2.5 py-2 text-left text-sm outline-none transition-colors focus-visible:ring-3 focus-visible:ring-ring/50",
active === i ? "bg-muted" : "hover:bg-muted"
)}
>
<span className="size-3 rounded-[3px] ring-1 ring-foreground/10 ring-inset" style={{ background: chartConfig[d.method].color }} aria-hidden />
<span className="min-w-0 truncate font-medium">{chartConfig[d.method].label}</span>
<span className="font-medium tabular-nums">{usd.format(d.amount)}</span>
<span aria-hidden />
<span className="text-xs text-muted-foreground">
{d.payments} {d.payments === 1 ? "payment" : "payments"}
</span>
<span className="text-right text-xs text-muted-foreground tabular-nums">{pct(d.amount)}</span>
</button>
</li>
))}
</ul>
</div>
</CardContent>
<CardFooter className="flex-col items-start gap-1 text-sm sm:flex-row sm:items-center sm:justify-between">
<p className="font-medium">
{COUNT} payments, {usd.format(Math.round(TOTAL / COUNT))} on average
</p>
<p className="text-muted-foreground">Card payouts land in 2 days, transfers in 1 to 3</p>
</CardFooter>
</Card>
)
}npx shadcn@latest add https://dresscodeui.com/r/dresscode/charts-radial.json"use client"
// Quarter goals as radial progress rings: one ring per goal on a faint track, the days left in the
// centre, and a list that names each ring with its figure, its target and whether it is on pace.
import { PolarAngleAxis, RadialBar, RadialBarChart } from "recharts"
import { Badge } from "@/components/ui/badge"
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card"
import { type ChartConfig, ChartContainer } from "@/components/ui/chart"
// One hue in three strengths, mixed toward the card, so the rings read in any theme and either mode.
const chartConfig = {
revenue: { label: "Revenue", color: "var(--chart-1)" },
recurring: { label: "Monthly recurring", color: "color-mix(in oklab, var(--chart-1) 68%, var(--card))" },
clients: { label: "New clients", color: "color-mix(in oklab, var(--chart-1) 42%, var(--card))" },
} satisfies ChartConfig
type Goal = keyof typeof chartConfig
const usd = new Intl.NumberFormat("en-US", { style: "currency", currency: "USD", maximumFractionDigits: 0 })
// Sample data: Q4 2026 (Oct 1 to Dec 31) on Nov 24, day 55 of 92.
const DAYS_GONE = 55
const DAYS_IN_QUARTER = 92
const PACE = (DAYS_GONE / DAYS_IN_QUARTER) * 100
const GOALS: { goal: Goal; value: number; target: number; format: (n: number) => string }[] = [
{ goal: "revenue", value: 142600, target: 180000, format: usd.format },
{ goal: "recurring", value: 26400, target: 30000, format: (n) => `${usd.format(n)}/mo` },
{ goal: "clients", value: 8, target: 15, format: String },
]
const rows = GOALS.map((g) => {
const progress = Math.min(100, (g.value / g.target) * 100)
return { ...g, progress, onPace: progress >= PACE, fill: `var(--color-${g.goal})` }
})
const onPace = rows.filter((r) => r.onPace).length
const behind = rows.find((r) => !r.onPace)
export default function ChartsRadial() {
return (
<Card className="w-full max-w-2xl">
<CardHeader>
<CardTitle>Quarter goals</CardTitle>
<CardDescription>Q4 2026, October 1 to December 31</CardDescription>
</CardHeader>
<CardContent className="grid items-center gap-6 sm:grid-cols-[minmax(0,230px)_1fr] sm:gap-8">
<div className="relative mx-auto aspect-square w-full max-w-[230px]">
<ChartContainer
config={chartConfig}
className="aspect-square w-full [&_.recharts-radial-bar-background-sector]:fill-foreground/8 [&_g[tabindex]]:outline-hidden"
aria-hidden
>
{/* The first ring in the data is the innermost, so the list's first goal goes last. */}
<RadialBarChart
data={rows.map(({ goal, progress, fill }) => ({ goal, progress, fill })).reverse()}
startAngle={90}
endAngle={-270}
innerRadius="40%"
outerRadius="100%"
barSize={15}
accessibilityLayer={false}
>
<PolarAngleAxis type="number" domain={[0, 100]} tick={false} axisLine={false} />
<RadialBar dataKey="progress" background cornerRadius={8} />
</RadialBarChart>
</ChartContainer>
<div className="pointer-events-none absolute inset-0 flex flex-col items-center justify-center text-center">
<span className="text-2xl font-semibold tracking-tight tabular-nums">{DAYS_IN_QUARTER - DAYS_GONE}</span>
<span className="text-xs text-muted-foreground">days left</span>
</div>
</div>
<ul className="grid gap-4" aria-label="Goals">
{rows.map((r) => (
<li key={r.goal} className="grid grid-cols-[auto_1fr_auto] items-start gap-x-3 gap-y-1">
<span className="mt-1 size-3 rounded-full ring-1 ring-foreground/10 ring-inset" style={{ background: chartConfig[r.goal].color }} aria-hidden />
<div className="min-w-0">
<p className="flex flex-wrap items-center gap-x-2 gap-y-1 font-medium">
{chartConfig[r.goal].label}
<Badge variant={r.onPace ? "secondary" : "outline"}>{r.onPace ? "On pace" : "Behind pace"}</Badge>
</p>
<p className="mt-0.5 text-sm text-muted-foreground tabular-nums">
{r.format(r.value)} of {r.format(r.target)}
</p>
</div>
<p className="text-lg font-semibold tabular-nums">
{Math.round(r.progress)}%<span className="sr-only"> of the target</span>
</p>
</li>
))}
</ul>
</CardContent>
<CardFooter className="flex-col items-start gap-1 text-sm sm:flex-row sm:items-center sm:justify-between">
<p className="font-medium">
{onPace} of {rows.length} goals on pace, {Math.round(PACE)}% of the quarter gone
</p>
{behind ? (
<p className="text-muted-foreground">
{chartConfig[behind.goal].label} needs {behind.format(behind.target - behind.value)} more by December 31
</p>
) : null}
</CardFooter>
</Card>
)
}KPI cards with sparklines
Four figures with a change badge that knows good from bad, and a 12-week sparkline each.
npx shadcn@latest add https://dresscodeui.com/r/dresscode/charts-kpi-sparklines.json"use client"
// A row of four KPI cards: the figure, how it moved against the four weeks before (green or red by
// whether the move is good for that figure, not by its direction), and a 12-week sparkline with a
// tooltip per week.
import * as React from "react"
import { Minus, TrendingDown, TrendingUp } from "lucide-react"
import { Area, AreaChart, ReferenceDot, XAxis, YAxis } from "recharts"
import { Badge } from "@/components/ui/badge"
import { Card, CardAction, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
import { type ChartConfig, ChartContainer, ChartTooltip, ChartTooltipContent } from "@/components/ui/chart"
const usd = new Intl.NumberFormat("en-US", { style: "currency", currency: "USD", maximumFractionDigits: 0 })
const dayShort = new Intl.DateTimeFormat("en-US", { month: "short", day: "numeric", timeZone: "UTC" })
// Sample data: 12 weeks, each starting on a Monday, the last one being the week of Nov 23, 2026.
const WEEKS = Array.from({ length: 12 }, (_, i) => new Date(Date.UTC(2026, 8, 7 + i * 7)).toISOString().slice(0, 10))
type Kpi = {
id: string
label: string
values: number[]
/** How the card's figure is made from the weekly values. */
figure: "last4" | "latest"
format: (n: number) => string
/** The tooltip figure for one week, when it needs more words than the card figure. */
tip?: (n: number) => string
/** Whether a rise is good news (revenue) or bad news (overdue invoices). */
better: "up" | "down"
change: "percent" | "days" | "count"
note: string
}
const KPIS: Kpi[] = [
{
id: "revenue",
label: "Revenue, last 4 weeks",
values: [9840, 10420, 9310, 10960, 11240, 10580, 11870, 12150, 11460, 12690, 13020, 12480],
figure: "last4",
format: usd.format,
better: "up",
change: "percent",
note: "Best four weeks since March",
},
{
id: "outstanding",
label: "Outstanding",
values: [16800, 17400, 16100, 15900, 16700, 15200, 14800, 15600, 14100, 13700, 13300, 12940],
figure: "latest",
format: usd.format,
better: "down",
change: "percent",
note: "Across 23 open invoices",
},
{
id: "days",
label: "Days to get paid",
values: [24, 23, 23, 22, 22, 21, 21, 20, 20, 19, 19, 18],
figure: "latest",
format: (n) => `${n} days`,
better: "down",
change: "days",
note: "Average over each week",
},
{
id: "overdue",
label: "Overdue invoices",
values: [4, 5, 5, 4, 6, 5, 5, 6, 6, 6, 8, 7],
figure: "latest",
format: String,
tip: (n) => `${n} overdue`,
better: "down",
change: "count",
note: "3 of them over 30 days late",
},
]
const chartConfig = { value: { label: "Value", color: "var(--chart-1)" } } satisfies ChartConfig
function summarize(k: Kpi) {
const v = k.values
const now = k.figure === "last4" ? v.slice(-4).reduce((a, b) => a + b, 0) : v[v.length - 1]
const then = k.figure === "last4" ? v.slice(-8, -4).reduce((a, b) => a + b, 0) : v[v.length - 5]
const delta = now - then
const rose = delta > 0
const good = delta === 0 || (k.better === "up" ? rose : !rose)
const sign = delta > 0 ? "+" : delta < 0 ? "−" : ""
const text =
k.change === "percent"
? `${sign}${Math.abs((delta / then) * 100).toFixed(1)}%`
: k.change === "days"
? `${sign}${Math.abs(delta)} ${Math.abs(delta) === 1 ? "day" : "days"}`
: `${sign}${Math.abs(delta)}`
return { now, delta, rose, good, text }
}
function Sparkline({ kpi }: { kpi: Kpi }) {
const data = kpi.values.map((value, i) => ({ week: WEEKS[i], value }))
const last = data[data.length - 1]
const gradient = `spark-${React.useId().replace(/:/g, "")}`
return (
<ChartContainer config={chartConfig} className="aspect-auto h-14 w-full [&_g[tabindex]]:outline-hidden" aria-hidden>
<AreaChart data={data} margin={{ top: 6, right: 6, bottom: 2, left: 6 }} accessibilityLayer={false}>
<defs>
<linearGradient id={gradient} x1="0" y1="0" x2="0" y2="1">
<stop offset="0%" stopColor="var(--color-value)" stopOpacity={0.32} />
<stop offset="100%" stopColor="var(--color-value)" stopOpacity={0} />
</linearGradient>
</defs>
<XAxis dataKey="week" hide />
<YAxis hide domain={["dataMin", "dataMax"]} />
<ChartTooltip
cursor={{ stroke: "var(--border)" }}
content={
<ChartTooltipContent
hideIndicator
labelFormatter={(w) => `Week of ${dayShort.format(new Date(`${w}T00:00:00Z`))}`}
formatter={(value) => <span className="font-medium text-foreground tabular-nums">{(kpi.tip ?? kpi.format)(Number(value))}</span>}
/>
}
/>
<Area
dataKey="value"
type="monotone"
stroke="var(--color-value)"
strokeWidth={2}
fill={`url(#${gradient})`}
dot={false}
activeDot={{ r: 3, fill: "var(--color-value)", stroke: "var(--card)", strokeWidth: 2 }}
/>
<ReferenceDot x={last.week} y={last.value} r={3} fill="var(--color-value)" stroke="var(--card)" strokeWidth={2} />
</AreaChart>
</ChartContainer>
)
}
export default function ChartsKpiSparklines() {
const headingId = React.useId()
return (
<section className="w-full max-w-6xl" aria-labelledby={headingId}>
<div className="mb-4 flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1">
<h2 id={headingId} className="text-base font-semibold">
Overview
</h2>
<p className="text-sm text-muted-foreground">Changes compare with the 4 weeks before · Sparklines show 12 weeks</p>
</div>
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-4">
{KPIS.map((k) => {
const s = summarize(k)
const first = k.values[0]
return (
<Card key={k.id}>
<CardHeader>
<CardDescription>{k.label}</CardDescription>
<CardTitle className="text-2xl font-semibold tracking-tight tabular-nums">{k.format(s.now)}</CardTitle>
<CardAction>
<Badge variant={s.good ? "secondary" : "destructive"}>
{s.delta === 0 ? <Minus aria-hidden /> : s.rose ? <TrendingUp aria-hidden /> : <TrendingDown aria-hidden />}
{s.text}
<span className="sr-only">{s.good ? ", a good change" : ", a change for the worse"}</span>
</Badge>
</CardAction>
</CardHeader>
<CardContent className="grid gap-2">
<Sparkline kpi={k} />
<p className="sr-only">
Over 12 weeks: from {k.format(first)} to {k.format(k.values[k.values.length - 1])}.
</p>
<p className="text-xs text-muted-foreground">{k.note}</p>
</CardContent>
</Card>
)
})}
</div>
</section>
)
}npx shadcn@latest add https://dresscodeui.com/r/dresscode/charts-bar-horizontal.json"use client"
// Top clients by revenue: horizontal bars with the client on the left and the amount at the end of each
// bar. The top three keep the full color; the tooltip adds the share of revenue and the change on 2025.
import { Bar, BarChart, LabelList, XAxis, YAxis } from "recharts"
import { Button } from "@/components/ui/button"
import { Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card"
import { type ChartConfig, ChartContainer, ChartTooltip, ChartTooltipContent } from "@/components/ui/chart"
const chartConfig = {
revenue: { label: "Revenue", color: "var(--chart-1)" },
rest: { label: "Revenue", color: "color-mix(in oklab, var(--chart-1) 45%, var(--card))" },
} satisfies ChartConfig
// Sample data: revenue by client, January 1 to November 24, 2026, against the same stretch of 2025.
const REVENUE_YTD = 470_200
const CLIENTS = [
{ client: "Fernwood Studio", revenue: 64200, lastYear: 51800, invoices: 22 },
{ client: "Kato & Lee", revenue: 52800, lastYear: 55100, invoices: 11 },
{ client: "Pellucid Health", revenue: 41350, lastYear: 28900, invoices: 14 },
{ client: "Northgate Logistics", revenue: 33900, lastYear: 30400, invoices: 9 },
{ client: "Marlow & Finch", revenue: 27450, lastYear: 0, invoices: 8 },
{ client: "Bluefield Schools", revenue: 21600, lastYear: 19750, invoices: 6 },
{ client: "Quarry Lane Coffee", revenue: 18240, lastYear: 16300, invoices: 12 },
].map((c, i) => ({ ...c, fill: i < 3 ? "var(--color-revenue)" : "var(--color-rest)" }))
type Client = (typeof CLIENTS)[number]
const TOP3 = CLIENTS.slice(0, 3).reduce((n, c) => n + c.revenue, 0)
const usd = new Intl.NumberFormat("en-US", { style: "currency", currency: "USD", maximumFractionDigits: 0 })
const usdShort = new Intl.NumberFormat("en-US", { style: "currency", currency: "USD", notation: "compact", maximumFractionDigits: 1 })
export default function ChartsBarHorizontal() {
return (
<Card className="w-full max-w-2xl">
<CardHeader>
<CardTitle>Top clients by revenue</CardTitle>
<CardDescription>January 1 to November 24, 2026</CardDescription>
<CardAction className="text-right">
<p className="text-2xl font-semibold tracking-tight tabular-nums">{Math.round((TOP3 / REVENUE_YTD) * 100)}%</p>
<p className="text-xs text-muted-foreground">of revenue from the top three</p>
</CardAction>
</CardHeader>
<CardContent>
<ChartContainer config={chartConfig} className="aspect-auto h-[300px] w-full [&_.recharts-cartesian-axis-tick-value]:fill-foreground rounded-md has-[.recharts-surface:focus-visible]:ring-3 has-[.recharts-surface:focus-visible]:ring-ring/50 [&_g[tabindex]]:outline-hidden">
<BarChart data={CLIENTS} layout="vertical" margin={{ top: 0, right: 52, bottom: 0, left: 0 }} barCategoryGap="22%">
<XAxis type="number" dataKey="revenue" hide />
<YAxis
type="category"
dataKey="client"
tickLine={false}
axisLine={false}
width={156}
tickMargin={6}
tick={{ fontSize: 12 }}
/>
<ChartTooltip
cursor={{ fill: "var(--muted)", opacity: 0.6 }}
content={
<ChartTooltipContent
className="min-w-52"
formatter={(value, _name, item) => {
const c = item.payload as Client
const change = c.lastYear ? ((c.revenue - c.lastYear) / c.lastYear) * 100 : null
return (
<div className="grid w-full gap-1">
<div className="flex items-center gap-2">
<span className="size-2.5 shrink-0 rounded-[2px]" style={{ background: c.fill }} />
<span className="text-muted-foreground">Revenue</span>
<span className="ml-auto font-medium text-foreground tabular-nums">{usd.format(Number(value))}</span>
</div>
<div className="flex items-center gap-2 pl-4.5 text-muted-foreground">
Share of revenue
<span className="ml-auto text-foreground tabular-nums">{((c.revenue / REVENUE_YTD) * 100).toFixed(1)}%</span>
</div>
<div className="flex items-center gap-2 pl-4.5 text-muted-foreground">
On 2025
<span className="ml-auto text-foreground tabular-nums">
{change == null ? "New client" : `${change >= 0 ? "+" : "−"}${Math.abs(change).toFixed(0)}%`}
</span>
</div>
<div className="flex items-center gap-2 pl-4.5 text-muted-foreground">
Invoices
<span className="ml-auto text-foreground tabular-nums">{c.invoices}</span>
</div>
</div>
)
}}
/>
}
/>
<Bar dataKey="revenue" radius={4} maxBarSize={30}>
<LabelList
dataKey="revenue"
position="right"
offset={8}
className="fill-foreground tabular-nums"
fontSize={12}
formatter={(v) => usdShort.format(Number(v))}
/>
</Bar>
</BarChart>
</ChartContainer>
<table className="sr-only">
<caption>Top clients by revenue, 2026 so far</caption>
<thead>
<tr>
<th scope="col">Client</th>
<th scope="col">Revenue</th>
<th scope="col">Share of revenue</th>
<th scope="col">Invoices</th>
</tr>
</thead>
<tbody>
{CLIENTS.map((c) => (
<tr key={c.client}>
<th scope="row">{c.client}</th>
<td>{usd.format(c.revenue)}</td>
<td>{((c.revenue / REVENUE_YTD) * 100).toFixed(1)}%</td>
<td>{c.invoices}</td>
</tr>
))}
</tbody>
</table>
</CardContent>
<CardFooter className="flex-wrap justify-between gap-x-4 gap-y-2 text-sm">
<p className="text-muted-foreground">
<span className="font-medium text-foreground">{usd.format(TOP3)}</span> of {usd.format(REVENUE_YTD)} came from three clients
</p>
<Button variant="outline" size="sm">
All clients
</Button>
</CardFooter>
</Card>
)
}