Migrating from Recharts

Move React charts from Recharts (or shadcn/ui charts) to Bklit UI. Component-by-component mapping, before and after code, and an AI prompt to do it for you.

Bklit UI and Recharts share the same idea: you build a chart from composable React components such as <LineChart>, <Line> and <XAxis>. Most charts move over in a few minutes. This guide covers the differences, maps every common Recharts component to its Bklit equivalent, and gives you a prompt to hand the work to a coding agent.

It also applies to shadcn/ui charts and Tremor charts, which are both built on Recharts. Not sure Bklit is the right fit? Read Bklit UI vs Recharts.

What changes

  • The code lives in your project. Charts install with the shadcn CLI instead of from npm, so you can open and change any of them.
  • Line, area and composed charts use dates on the x axis. Each row needs a Date under date (or the key you pass to xDataKey). Categorical x values, such as month names, belong in a bar chart.
  • No ResponsiveContainer. Charts fill their parent's width and take their height from aspectRatio (default "2 / 1").
  • Colours come from CSS variables such as var(--chart-line-primary), so charts follow your theme and dark mode. See Theming.
  • Motion is built in. Lines draw in, data changes morph, and tooltips follow with springs. There is nothing to configure.

Migrate with an AI agent

Install the Bklit UI agent skills so your agent knows the component APIs, then paste this prompt:

Migrate every Recharts chart in this project to Bklit UI.

1. Find files that import from "recharts" (including shadcn/ui chart components
   in components/ui/chart.tsx and Tremor charts).
2. For each chart type used, install the Bklit chart with
   `npx shadcn@latest add @bklit/<chart>-chart` (for example @bklit/line-chart).
3. Rewrite each chart with Bklit components, following
   https://bklit.com/docs/migrating-from-recharts:
   - Remove ResponsiveContainer; size with aspectRatio on the chart.
   - Line/Area/Composed charts: convert x values to Date objects under `date`.
   - CartesianGrid -> <Grid horizontal />, Tooltip -> <ChartTooltip />.
   - BarChart XAxis/YAxis -> <BarXAxis /> / <BarYAxis />.
   - Use CSS variables (var(--chart-line-primary), var(--chart-line-secondary))
     for colours.
4. Keep the same data, series and labels. Don't change unrelated code.
5. When nothing imports "recharts" any more, remove the package and run the
   type checker.

Migrate by hand

1. Add the Bklit charts you use

Make sure your project is set up for shadcn/ui (see Installation), then add each chart type you need:

npx shadcn@latest add @bklit/line-chart @bklit/bar-chart @bklit/pie-chart

2. Reshape time-series data

Recharts reads any key for the x axis. Bklit line, area and composed charts use a time scale, so give each row a Date:

// Recharts
const data = [{ day: "2026-01-01", users: 1200 }];

// Bklit UI
const data = [{ date: new Date("2026-01-01"), users: 1200 }];

If your dates live under another key, pass it with xDataKey.

3. Swap the components

RechartsBklit UINotes
ResponsiveContainer—Remove it. Set aspectRatio on the chart, or give the parent a size
LineChart, AreaChartLineChart, AreaChartSame data prop
BarChartBarChartCategory key via xDataKey (default "name")
BarChart layout="vertical"BarChart orientation="horizontal"
ComposedChartComposedChartUse SeriesBar for bars on a time axis
Line dataKey strokeLine dataKey strokeNo dot={false} needed: dots only show on hover
Area dataKey fillArea dataKey fillGradient fill by default; tune with fillOpacity
Bar dataKey fill radiusBar dataKey fill lineCaplineCap="round" or a radius in pixels
Bar stackIdBarChart stackedStacking is set on the chart
CartesianGridGridhorizontal / vertical props
XAxis, YAxisXAxis, YAxisIn bar charts: BarXAxis, BarYAxis
TooltipChartTooltipFormat values with rows, or replace it with content
LegendLegendRendered next to the chart. See Legend
ReferenceAreaReferenceAreaSee Reference Area
BrushChartBrushSee Brush
PieChart, Pie, CellPieChart, PieSliceOne PieSlice per data item; innerRadius on PieChart makes a donut
ScatterChart, RadarChart, FunnelChart, SankeyScatterChart, RadarChart, FunnelChart, SankeyChartSee each chart's docs page

4. Remove Recharts

When nothing imports recharts any more:

npm uninstall recharts

If you used shadcn/ui charts, you can also delete components/ui/chart.tsx once nothing imports it.

Before and after

Line chart

// Recharts
<ResponsiveContainer width="100%" height={300}>
  <LineChart data={data}>
    <CartesianGrid vertical={false} />
    <XAxis dataKey="day" />
    <Tooltip />
    <Line dataKey="users" stroke="#2563eb" dot={false} />
    <Line dataKey="pageviews" stroke="#a855f7" dot={false} />
  </LineChart>
</ResponsiveContainer>
// Bklit UI
<LineChart data={data} aspectRatio="2 / 1">
  <Grid horizontal />
  <Line dataKey="users" />
  <Line dataKey="pageviews" stroke="var(--chart-line-secondary)" />
  <XAxis />
  <ChartTooltip />
</LineChart>

Stacked bar chart

// Recharts
<BarChart data={data}>
  <XAxis dataKey="month" />
  <Bar dataKey="desktop" stackId="a" fill="#2563eb" />
  <Bar dataKey="mobile" stackId="a" fill="#a855f7" radius={[4, 4, 0, 0]} />
</BarChart>
// Bklit UI
<BarChart data={data} xDataKey="month" stacked>
  <Grid horizontal />
  <Bar dataKey="desktop" fill="var(--chart-line-primary)" />
  <Bar dataKey="mobile" fill="var(--chart-line-secondary)" />
  <BarXAxis />
  <ChartTooltip />
</BarChart>

Donut chart

// Recharts
<PieChart width={280} height={280}>
  <Pie data={data} dataKey="value" nameKey="label" innerRadius={70}>
    {data.map((item) => (
      <Cell key={item.label} fill={item.color} />
    ))}
  </Pie>
</PieChart>
// Bklit UI: each item has `label`, `value` and an optional `color`
<PieChart data={data} size={280} innerRadius={70}>
  {data.map((item, index) => (
    <PieSlice key={item.label} index={index} />
  ))}
</PieChart>

Tooltip formatting

// Recharts
<Tooltip formatter={(value) => `$${value.toLocaleString()}`} />
// Bklit UI
<ChartTooltip
  rows={(point) => [
    {
      color: "var(--chart-line-primary)",
      label: "Revenue",
      value: `$${point.revenue.toLocaleString()}`,
    },
  ]}
/>

Troubleshooting

The line chart is empty or the x axis shows the wrong dates

Line, area and composed charts need Date objects on the x axis. Convert strings with new Date(value), and pass xDataKey if the key isn't date.

The chart is too tall or too short

Bklit charts size from their parent's width. Set aspectRatio (for example "3 / 1"), or give the chart a fixed height with style.

My colours didn't carry over

Pass any CSS colour to stroke or fill, or define theme colours once as CSS variables. See Theming.

Is there a Bklit equivalent for every Recharts chart?

Most, and many that Recharts doesn't have, such as candlestick, Gantt and heatmap charts. There is no treemap yet.