Components

Chart

Animated React charts built on shadcn/ui and Recharts v3: themed ChartContainer, tooltip and legend helpers for dark dashboards, plus an area chart with soft fills that draw in, a bar chart with hover highlights and a radial progress stat that counts up.

  • Drop-in shadcn API
  • Recharts v3
  • Themed tooltips
  • Accessible data tables
  • prefers-reduced-motion

Visitors

Unique visitors per day

Visitors
dateDesktopMobile
Oct 25339259
Oct 26321280
Oct 27300295
Oct 28279300
Oct 29263294
Oct 30254279
Oct 31254260
Nov 1263243
Nov 2279232
Nov 3301230
Nov 4325235
Nov 5347242
Nov 6366245
Nov 7378240
Nov 8385227
Nov 9386208
Nov 10384188
Nov 11382174
Nov 12382169
Nov 13388176
Nov 14399192
Nov 15415212
Nov 16436231
Nov 17457243
Nov 18477247
Nov 19491245
Nov 20498241
Nov 21496240
Nov 22485246
Nov 23467262

Installation

$ npx shadcn@latest add https://duskui.com/r/chart.json

Adds components/ui/chart.tsx with the shadcn exports, typed for Recharts v3. Each config entry becomes a CSS variable scoped to its chart (desktop → var(--color-desktop)). useChartReducedMotion() is exported so you can pass isAnimationActive explicitly.

Usage

visitors-chart.tsx
"use client"

import { Bar, BarChart, XAxis } from "recharts"
import {
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  useChartReducedMotion,
  type ChartConfig,
} from "@/components/ui/chart"

const data = [
  { month: "Jan", desktop: 186 },
  { month: "Feb", desktop: 305 },
]

const config = {
  desktop: { label: "Desktop", color: "var(--chart-1)" },
} satisfies ChartConfig

export function VisitorsChart() {
  const reduced = useChartReducedMotion()
  return (
    <ChartContainer config={config} title="Desktop visitors" className="h-56 w-full">
      <BarChart data={data}>
        <XAxis dataKey="month" tickLine={false} axisLine={false} />
        <ChartTooltip content={<ChartTooltipContent />} />
        <Bar dataKey="desktop" fill="var(--color-desktop)" radius={4} isAnimationActive={!reduced} />
      </BarChart>
    </ChartContainer>
  )
}

Examples

Default

A grouped bar chart with ChartTooltipContent and ChartLegendContent. Labels and colors come from the config, and axis ticks and grid lines pick up the DuskUI tokens.

Line indicator tooltip

indicator switches the tooltip swatch between dot, line and dashed. Focus the chart and use the arrow keys to move the tooltip — Recharts' accessibility layer is on by default in v3.

Blocks

Ready-made variations composed from the base component with Motion. Each installs on its own and pulls in its dependencies automatically.

Area Chart

A dashboard card with softly filled areas that draw in from the left, a readout that follows the pointer or keyboard, and range buttons with a gliding pill. The readout has a fixed height, so hovering never shifts the layout. A visually hidden table carries the numbers for screen readers.

Visitors

Unique visitors per day

Visitors
dateDesktopMobile
Oct 25339259
Oct 26321280
Oct 27300295
Oct 28279300
Oct 29263294
Oct 30254279
Oct 31254260
Nov 1263243
Nov 2279232
Nov 3301230
Nov 4325235
Nov 5347242
Nov 6366245
Nov 7378240
Nov 8385227
Nov 9386208
Nov 10384188
Nov 11382174
Nov 12382169
Nov 13388176
Nov 14399192
Nov 15415212
Nov 16436231
Nov 17457243
Nov 18477247
Nov 19491245
Nov 20498241
Nov 21496240
Nov 22485246
Nov 23467262
$ npx shadcn@latest add https://duskui.com/r/area-chart.json
PropTypeDefaultDescription
title / descriptionReactNode—Card heading. A string title also names the chart.
dataRecord<string, string | number>[]—Rows, oldest first. Keep it static or memoized.
configChartConfig—One entry per series; keys are data keys.
indexstring—Key of the x value.
ranges / defaultRange{ label, points }[] / string—Range buttons that show the last N points.
stackedbooleanfalseStack the series instead of overlapping.
labelFormatter / valueFormatter(value) => string—Format x and y values. Use fixed locales to keep SSR stable.
chartLabelstring—Accessible name when the title isn't a string.

Bar Chart

Hovering a bar dims the others, outlines the hovered one and swaps the headline to its value. Bars grow in on mount, and the keyboard-active bar is outlined the same way.

Monthly revenue

January – August 2026

Monthly revenue
monthRevenue
Jan$18,400
Feb$21,900
Mar$19,300
Apr$26,700
May$24,100
Jun$31,200
Jul$29,800
Aug$34,600
$ npx shadcn@latest add https://duskui.com/r/bar-chart.json
PropTypeDefaultDescription
title / descriptionReactNode—Card heading. A string title also names the chart.
data / configRecord<string, string | number>[] / ChartConfig—Rows and the config entry for `dataKey`.
index / dataKeystring—Category key and value key.
summary"total" | "average" | "last""total"Headline when nothing is hovered.
valueFormatter(value: number) => string—Formats the headline, tooltip and table.
chartLabelstring—Accessible name when the title isn't a string.

Radial Stat

A rounded ring sweeps to the value while the number in the middle counts up with it (a Motion value, so the count never re-renders React). The figure is labelled with the exact value and percentage; the moving counter is hidden from screen readers.

72 of 100 GB · 72%
Resets in 6 days
Last 30 days
$ npx shadcn@latest add https://duskui.com/r/radial-stat.json
PropTypeDefaultDescription
value / maxnumber— / 100Current value and the value that fills the ring.
labelstring—What is measured; used in the accessible name.
unitstring—Shown after the number.
colorstring"var(--color-primary)"Ring color, any CSS color.
thicknessnumber0.14Ring thickness as a fraction of the radius.
caption / valueFormatterReactNode / (value: number) => string—Line under the ring and number formatting.

API Reference

Same parts as shadcn/ui: ChartContainer, ChartTooltip, ChartTooltipContent, ChartLegend, ChartLegendContent, ChartStyle and the ChartConfig type, plus useChart and useChartReducedMotion.

PropTypeDefaultDescription
configChartConfig—On ChartContainer: { [key]: { label?, icon?, color? | theme? } }.
titlestring—On ChartContainer: accessible name; renders the container as role="figure".
indicator"dot" | "line" | "dashed""dot"On ChartTooltipContent: swatch style.
hideLabel / hideIndicatorbooleanfalseOn ChartTooltipContent.
labelKey / nameKeystring—On ChartTooltipContent / ChartLegendContent: config lookup keys.
labelFormatter / formatterfunction—On ChartTooltipContent: custom heading and rows.
hideIconbooleanfalseOn ChartLegendContent.

Accessibility

  • ChartContainer takes a title that becomes the chart's accessible name (role="figure").
  • Recharts v3's accessibility layer is on: focus a chart and use the arrow keys to move the tooltip between points.
  • The blocks render a visually hidden data table, so screen readers get every value without hovering.
  • Under prefers-reduced-motion the blocks pass isAnimationActive={false}: series appear at their final shape and counters jump to the value.