Unified UI

Chart

A card wrapper for Recharts with consistent design system theming, pre-configured color palette, and responsive sizing.

Basic

A card wrapper for Recharts with consistent design system theming, pre-configured color palette, loading/empty states, and responsive sizing.

Monthly Revenue

Jan – Jun 2025

Installation

Install the component via the CLI in one command.

npx @work-rjkashyap/unified-ui add chart
pnpm dlx @work-rjkashyap/unified-ui add chart
npx @work-rjkashyap/unified-ui add chart
bunx @work-rjkashyap/unified-ui add chart

If you haven't initialized your project yet, run npx @work-rjkashyap/unified-ui init first. See the CLI docs for details.

Or install the full package

Use this approach if you prefer to install the entire design system as a dependency instead of copying individual components.

npm install @work-rjkashyap/unified-ui
pnpm add @work-rjkashyap/unified-ui
yarn add @work-rjkashyap/unified-ui
bun add @work-rjkashyap/unified-ui

Anatomy

import {
	ChartContainer,
	ChartTooltipContent,
	Badge,
} from "@work-rjkashyap/unified-ui";

Examples

Bar Chart

Weekly Sales

Last 5 weeks

Multi-Series Bar Chart

Revenue vs Expenses

Q1 – Q2 2025

Revenue
Expenses

Line Chart

Daily Visitors

This week

Area Chart

Users & Sessions

Growth over 6 months

Users
Sessions

Pie / Donut Chart

Traffic Sources

Device breakdown

Desktop (55%)
Mobile (30%)
Tablet (15%)

Loading State

Empty State

No data yet

Signups will appear here once recorded.


Chart Colors

The chartColors array provides 10 pre-defined colors that integrate with design system tokens:

import { chartColors } from "@work-rjkashyap/unified-ui";

<Bar dataKey="revenue" fill={chartColors[0]} />  // primary
<Bar dataKey="expenses" fill={chartColors[1]} /> // info
<Bar dataKey="profit" fill={chartColors[2]} />   // success
IndexTokenUsage
0var(--primary)Primary
1var(--info)Info
2var(--success)Success
3var(--warning)Warning
4var(--danger)Danger
5var(--secondary)Secondary
6var(--muted-foreground)Muted
7oklch skySky
8oklch emeraldEmerald
9oklch amberAmber

Props (ChartContainer)

PropTypeDefaultDescription
titlestringChart title.
descriptionstringChart description/subtitle.
heightnumber350Chart area height in pixels.
childrenReactNodeThe Recharts chart component(s).
footerReactNodeFooter content (legend, notes).
loadingbooleanfalseShows loading indicator.
loadingIndicatorReactNodeCustom loading indicator.
emptyContentReactNodeContent when chart has no data.
classNamestringAdditional CSS classes.

Props (ChartTooltipContent)

PropTypeDefaultDescription
labelstringTooltip header label.
payloadArray<{ name, value, color, fill }>Recharts tooltip payload.
activebooleanWhether tooltip is active.
formatter(value, name) => stringCustom value formatter.
classNamestringAdditional CSS classes.

Accessibility

  • Chart container uses semantic heading for title.
  • Footer content is associated with the chart visually.
  • Color palette is designed with sufficient contrast for both light and dark modes.

For accessible chart content, add aria-label or role="img" with a descriptive label to your Recharts ResponsiveContainer or chart wrapper.


Design Tokens

TokenUsage
--backgroundCard background
--foregroundTitle text
--muted-foregroundDescription, axis text
--borderCard and tooltip borders
--radius-lgCard border radius
--primaryChart color 1
--infoChart color 2
--successChart color 3

On this page