Getting Started

Set up D3 UI in your React or Next.js project with Tailwind CSS and D3.js.

Prerequisites

  • Node.js 18+ and npm/pnpm
  • React project (Next.js recommended)
  • Tailwind CSS installed

Install Tailwind CSS

Follow the official Tailwind setup guide if you haven’t already.

Install D3.js

Installing d3
npm install d3

Add the primitives components

./components/primitives/Axis.tsx
./components/primitives/Tooltip.tsx
./components/primitives/Tooltip.tsx

Add Components

Copy any component you want from our docs into your project’s components folder:

src/
  components/
    charts/
      LineChart.tsx

Use the Component

import LineChart from "@/components/charts/LineChart";

const data = [
  { x: 0, y: 10 },
  { x: 1, y: 30 },
  { x: 2, y: 20 },
];

export default function Example() {
  return <LineChart data={data} />;
}

That’s it! You’re ready to use D3 UI components in your app.