Components
Chart
A Recharts wrapper with tooltip, legend, and style helpers.
Chart is a thin wrapper around Recharts. It provides a ChartContainer that reads a config object, plus tooltip and legend components styled to match the rest of the UI.
Installation
pnpm dlx shadcn@latest add https://faber-ui.vercel.app/r/chart.jsonUsage
Chart components require "use client" because Recharts uses React context internally.
"use client";
import {
Bar,
BarChart,
CartesianGrid,
ChartContainer,
ChartTooltip,
ChartTooltipContent,
XAxis,
type ChartConfig,
} from "@/components/ui/chart";
const chartData = [
{ month: "January", desktop: 186 },
{ month: "February", desktop: 305 },
{ month: "March", desktop: 237 },
];
const chartConfig = {
desktop: {
label: "Desktop",
color: "var(--chart-1)",
},
} satisfies ChartConfig;
export default function Example() {
return (
<ChartContainer config={chartConfig} className="h-[200px] w-full">
<BarChart data={chartData}>
<CartesianGrid vertical={false} />
<XAxis dataKey="month" tickLine={false} axisLine={false} />
<ChartTooltip content={<ChartTooltipContent />} />
<Bar dataKey="desktop" fill="var(--color-desktop)" radius={4} />
</BarChart>
</ChartContainer>
);
}Examples
Bar chart
API
Each part forwards every prop of what it is built on, including className and render where Base UI supports it. The props column lists only what Faber UI adds on top.
| Part | Built on | Props |
|---|---|---|
ChartContainerdata-slot="chart" | <div>HTML |
|
ChartStyle | <style>HTML |
|
ChartTooltip | RechartsPrimitive.Tooltiprecharts | — |
ChartTooltipContent | <div>HTML |
|
ChartLegend | RechartsPrimitive.Legendrecharts | — |
ChartLegendContent | <div>HTML |
|
Area | Arearecharts | — |
AreaChart | AreaChartrecharts | — |
Bar | Barrecharts | — |
BarChart | BarChartrecharts | — |
CartesianGrid | CartesianGridrecharts | — |
Cell | Cellrecharts | — |
Line | Linerecharts | — |
LineChart | LineChartrecharts | — |
Pie | Pierecharts | — |
PieChart | PieChartrecharts | — |
PolarAngleAxis | PolarAngleAxisrecharts | — |
PolarGrid | PolarGridrecharts | — |
RadialBar | RadialBarrecharts | — |
RadialBarChart | RadialBarChartrecharts | — |
Radar | Radarrecharts | — |
RadarChart | RadarChartrecharts | — |
ReferenceLine | ReferenceLinerecharts | — |
XAxis | XAxisrecharts | — |
YAxis | YAxisrecharts | — |
Changelog
- v0.3.0ChartContainer accepts only color values made of safe characters, closing an injection path through the generated style tag.patch
- v0.1.0Accessibility, correctness, and token fixes across the kit, from a full code-smell audit.minor
Last updated on