Install and configure Mario Charts in your React project.
The easiest way to get started is using the Mario Charts CLI. It automatically handles dependencies, configuration, and file setup.
npx mario-charts@latest initnpx mario-charts@latest add bar-chartimport { BarChart } from "@/components/charts/bar-chart";
const data = [
{ month: "Jan", revenue: 4500 },
{ month: "Feb", revenue: 5200 },
{ month: "Mar", revenue: 4800 }
];
export function Dashboard() {
return (
<BarChart
data={data}
x="month"
y="revenue"
/>
);
}That's it! The CLI automatically installed dependencies, configured your project, and added the component files. You can now use Mario Charts components in your React application.
If you prefer to configure everything manually, follow these steps.
Install the required peer dependencies for Mario Charts components.
npm install framer-motion clsx tailwind-mergeAdd chart colors to your tailwind.config.ts file.
import type { Config } from "tailwindcss";
const config: Config = {
content: [
"./components/**/*.{js,ts,jsx,tsx,mdx}",
"./app/**/*.{js,ts,jsx,tsx,mdx}",
],
theme: {
extend: {
colors: {
chart: {
"1": "hsl(239 84% 67%)",
"2": "hsl(262 83% 58%)",
"3": "hsl(180 98% 31%)",
"4": "hsl(47 96% 53%)",
"5": "hsl(339 82% 67%)",
},
},
},
},
plugins: [],
};
export default config;Add chart color variables to your global CSS file.
@import "tailwindcss";
:root {
--chart-1: 239 84% 67%;
--chart-2: 262 83% 58%;
--chart-3: 180 98% 31%;
--chart-4: 47 96% 53%;
--chart-5: 339 82% 67%;
}Create lib/utils.ts for the utility function.
import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}That's it! You can now start using Mario Charts components in your project.
Need help? Explore the component library in the sidebar or check back soon for more documentation.