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
Visits over time
DateVisits
09-01140
09-02220
09-03175

Installation

New to this Registry? Complete the base setup before continuing.

npx shadcn@latest add @neumorphism-ui/chart

Install the shared base once, then add components and their dependencies with the CLI.

Registry JSON

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.

ComponentPropTypeDefaultDescription
ChartContainertitle / descriptionrequiredstring—Readable chart title and description.
ChartContainertable / tableLabelrequiredReactNode / string—A table from the same data and its disclosure label.
ChartContainerempty / emptyLabelboolean / string—The state to display when no records are available.
ChartTooltippropsRecharts 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.