Chart
Use Chart to present trends or comparisons alongside an exact, readable data alternative.
Preview
Daily visits
Show illustrative daily visit totals in a bar chart and expose the same values in a table.
Visits over time
Use the original data table for exact values.
View exact data
| Date | Visits |
|---|---|
| 09-01 | 140 |
| 09-02 | 220 |
| 09-03 | 175 |
Installation
New to this Registry? Complete the base setup before continuing.
npx shadcn@latest add @neumorphism-ui/chartInstall the shared base once, then add components and their dependencies with the CLI.
Usage
Give ChartContainer a title, description, and data table, then add a Recharts chart and tooltip. Keep series labels and values meaningful without relying only on color or hover.
"use client";
import { Bar, BarChart, XAxis } from "recharts";
import { ChartContainer, ChartTooltip } from "@/components/ui/chart";
const data = [{ day: "Mon", visits: 120 }, { day: "Tue", visits: 180 }];
export default function Example() {
return (
<ChartContainer title="Daily visits" description="Visits by day." tableLabel="View data"
table={<table><caption>Daily visits</caption><thead><tr><th scope="col">Day</th><th scope="col">Visits</th></tr></thead><tbody>{data.map(row => <tr key={row.day}><th scope="row">{row.day}</th><td>{row.visits}</td></tr>)}</tbody></table>}>
<BarChart data={data} accessibilityLayer>
<XAxis dataKey="day" />
<ChartTooltip />
<Bar dataKey="visits" name="Visits" fill="var(--primary)" />
</BarChart>
</ChartContainer>
);
}API Reference
Compose Recharts axes and series directly. Data marks stay flat and legible; neumorphic depth belongs to the surrounding surface.
| Component | Prop | Type | Default | Description |
|---|---|---|---|---|
ChartContainer | title / descriptionrequired | string | — | Readable chart title and description. |
ChartContainer | table / tableLabelrequired | ReactNode / string | — | A table from the same data and its disclosure label. |
ChartContainer | empty / emptyLabel | boolean / string | — | The state to display when no records are available. |
ChartTooltip | props | Recharts Tooltip props | — | Pass ordinary Recharts Tooltip options. |
Accessibility
- 01
Use accessibilityLayer, redundant line styles and labels, and an exact-data table.
- 02
Examples disable animation. Applications own the motion policy of custom series.