export const title = "Line & bar chart components"
export const description = "Free and open-source React line and bar chart components built for modern applications and websites. These line and bar charts are built using Recharts and styled with Tailwind CSS."
export const links = {
github: "https://github.com/untitleduico/react/tree/main/components/application/charts",
recharts: "https://recharts.org/en-US/api/LineChart",
}
import * as LineCharts from "@/components/application/charts/line-charts.story.tsx";
import * as BarCharts from "@/components/application/charts/bar-charts.story.tsx";
## Installation
You can add this line and bar charts component using our CLI or manually:
```bash
npx untitledui@latest add charts-base
```
As our line and bar charts component is built with [Recharts](https://recharts.org/en-US/), you'll need to install the dependencies:
```bash
npm install recharts
```
Copy the files below into your project:
Great! Now you can start using the line and bar charts components in your project by just copy/pasting our examples below.
## Chart examples
Below are examples and variations of this line and bar charts component:
### Line chart 01 {{ tocOnly:true }}
### Line chart 02 {{ tocOnly:true }}
### Line chart 03 {{ tocOnly:true }}
### Line chart 04 {{ tocOnly:true }}
### Bar chart 01 {{ tocOnly:true }}
### Bar chart 02 {{ tocOnly:true }}
### Bar chart 03 {{ tocOnly:true }}
## API reference
` at the x value and give each `` or `` its own `dataKey` such as `\"A\"`.",
},
{
question: "Which parts are Untitled UI and which are Recharts?",
answer: "`charts-base.tsx` only adds presentation helpers — `ChartTooltipContent`, `ChartLegendContent`, `ChartActiveDot`, and the `selectEvenlySpacedItems` utility. Everything structural (`ResponsiveContainer`, `AreaChart`, `BarChart`, `ComposedChart`, `XAxis`, `YAxis`, `CartesianGrid`, `Tooltip`, `Legend`, `Area`, `Bar`, `Line`, `Label`) is imported directly from `recharts`, so the entire Recharts API stays available to you. `npx untitledui@latest add charts-base` adds the helpers; for a manual setup, run `npm install recharts` and copy the file.",
},
{
question: "How do I use the styled tooltip?",
answer: "Pass it as the `content` of the Recharts tooltip: `} />`. It respects the `formatter` and `labelFormatter` you set on `` itself — the examples use `formatter={(value) => Number(value).toLocaleString()}` for values and a `labelFormatter` that turns the date key into a readable month and year.",
},
{
question: "How do I change the color of a series?",
answer: "No colors are hardcoded. Each series sets `stroke=\"currentColor\"` (lines and areas) or `fill=\"currentColor\"` (bars) and takes its actual color from a Tailwind class on the series' `className`, such as `text-utility-brand-600` or `text-utility-brand-400`. Change that utility class to recolor the series, and it will follow your theme in both light and dark mode. Gradient area fills work the same way: the `` elements inside the `` use `stopColor=\"currentColor\"` with their own utility class.",
},
{
question: "Can I customize the legend?",
answer: "Yes, pass `content={}` to Recharts' `