npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

shadcn-chart

v0.2.1

Published

Headless and styled chart components built with shadcn/ui conventions

Readme

shadcn-chart

npm version License: MIT TypeScript

Beautiful, customizable chart components built with shadcn/ui conventions and Recharts.

✨ Features

  • 📊 5 Chart Types - Area, Bar, Line, Pie, and Radial charts
  • 🎨 Multiple Variants - Each chart has different display modes (stacked, gradient, interactive, etc.)
  • 🌙 Dark Mode Ready - Built-in CSS variables for light/dark themes
  • 📱 Responsive - Works on all screen sizes
  • 🔧 Highly Customizable - Extensive props for fine-tuning
  • 📦 Tree-shakeable - Only import what you need
  • 💪 TypeScript - Full type definitions included

📦 Installation

Option 1: shadcn CLI (Recommended)

Add individual chart components directly to your project:

# Install a single chart
npx shadcn add https://mnhtng.github.io/shadcn-chart/public/r/area-chart.json

# Or install all charts
npx shadcn add https://mnhtng.github.io/shadcn-chart/public/r/area-chart.json \
  https://mnhtng.github.io/shadcn-chart/public/r/bar-chart.json \
  https://mnhtng.github.io/shadcn-chart/public/r/line-chart.json \
  https://mnhtng.github.io/shadcn-chart/public/r/pie-chart.json \
  https://mnhtng.github.io/shadcn-chart/public/r/radial-chart.json

This copies the component source to your project, allowing full customization.

Option 2: npm Package

npm install shadcn-chart
# or
yarn add shadcn-chart
# or
pnpm add shadcn-chart

Peer Dependencies

npm install react react-dom recharts lucide-react tailwindcss tw-animate-css

Note: This package requires Tailwind CSS v4+ and uses the new CSS-first configuration.

🚀 Quick Start

1. Import Styles

Add to your root CSS file (e.g., index.css or globals.css):

@import "shadcn-chart/styles";

Or import in your main entry file:

// Next.js: app/layout.tsx or pages/_app.tsx
// Vite: main.tsx
import 'shadcn-chart/styles';

2. Use Components

import { AreaChartComponent } from 'shadcn-chart';

const chartData = [
  { month: "January", desktop: 186, mobile: 80 },
  { month: "February", desktop: 305, mobile: 200 },
  { month: "March", desktop: 237, mobile: 120 },
];

const chartConfig = {
  desktop: { label: "Desktop", color: "var(--chart-1)" },
  mobile: { label: "Mobile", color: "var(--chart-2)" },
};

export default function MyChart() {
  return (
    <AreaChartComponent
      title="Website Traffic"
      description="Visitor statistics"
      data={chartData}
      chartConfig={chartConfig}
      variant="gradient"
      showLegend
    />
  );
}

📊 Components

AreaChartComponent

| Prop | Type | Default | Description | |------|------|---------|-------------| | data | Array<Record<string, string \| number>> | required | Chart data array | | chartConfig | ChartConfig | required | Color and label configuration | | variant | 'default' \| 'linear' \| 'step' \| 'stacked' \| 'stacked-expanded' \| 'gradient' \| 'legend' \| 'interactive' | 'default' | Display variant | | title | string | - | Card title | | description | string | - | Card description | | xAxisKey | string | 'month' | Data key for X-axis | | showGrid | boolean | true | Show grid lines | | showTooltip | boolean | true | Show tooltip on hover | | showLegend | boolean | auto | Show chart legend | | showDots | boolean | auto | Show data point dots | | useGradient | boolean | auto | Use gradient fill |

BarChartComponent

| Prop | Type | Default | Description | |------|------|---------|-------------| | data | Array<Record<string, string \| number>> | required | Chart data array | | chartConfig | ChartConfig | required | Color and label configuration | | variant | 'default' \| 'horizontal' \| 'multiple' \| 'stacked' \| 'stacked-legend' \| 'label' \| 'negative' \| 'mixed' \| 'interactive' | 'default' | Display variant | | layout | 'vertical' \| 'horizontal' | auto | Bar orientation | | showLabels | boolean | auto | Show value labels on bars | | barRadius | number \| [number, number, number, number] | auto | Bar corner radius |

LineChartComponent

| Prop | Type | Default | Description | |------|------|---------|-------------| | data | Array<Record<string, string \| number>> | required | Chart data array | | chartConfig | ChartConfig | required | Color and label configuration | | dot | boolean \| function | false | Show/customize data points | | yAxisConfig | object | - | Y-axis configuration | | toggleOptions | object | - | Time period toggle buttons |

PieChartComponent

| Prop | Type | Default | Description | |------|------|---------|-------------| | data | PieChartData[] | required | Pie chart data with category, value, percentage | | chartConfig | ChartConfig | required | Color and label configuration | | innerRadius | number | 0 | Donut hole radius | | outerRadius | number | 100 | Pie outer radius | | showActiveSection | boolean | false | Animate active section on hover | | paddingAngle | number | 0 | Gap between segments |

RadialChartShapeComponent

| Prop | Type | Default | Description | |------|------|---------|-------------| | data | RadialChartData | required | Single data object with percentage | | chartConfig | ChartConfig | required | Color and label configuration | | centerLabel | string | - | Label in center of chart | | innerRadius | number | 80 | Inner radius | | outerRadius | number | 130 | Outer radius | | animationDuration | number | 2.5 | Animation duration in seconds |

🎨 Theming

The package uses CSS variables for theming. Override these in your CSS:

:root {
  --chart-1: oklch(0.646 0.222 41.116);
  --chart-2: oklch(0.6 0.118 184.704);
  --chart-3: oklch(0.398 0.07 227.392);
  --chart-4: oklch(0.828 0.189 84.429);
  --chart-5: oklch(0.769 0.188 70.08);
}

.dark {
  --chart-1: oklch(0.488 0.243 264.376);
  --chart-2: oklch(0.696 0.17 162.48);
  --chart-3: oklch(0.769 0.188 70.08);
  --chart-4: oklch(0.627 0.265 303.9);
  --chart-5: oklch(0.645 0.246 16.439);
}

⚙️ Tailwind CSS Configuration

Tailwind v4

If you're using a bundler like Vite with @tailwindcss/vite, you need to add a @source directive so Tailwind can scan the package's utility classes:

@import "tailwindcss";

@source "../node_modules/shadcn-chart";

Tailwind v3

Add the package to your content paths:

// tailwind.config.js
module.exports = {
  content: [
    './src/**/*.{js,ts,jsx,tsx}',
    './node_modules/shadcn-chart/dist/**/*.{js,mjs}',
  ],
};

🌐 Framework Compatibility

| Framework | Status | |-----------|--------| | Next.js (App Router) | ✅ Supported | | Next.js (Pages Router) | ✅ Supported | | Vite | ✅ Supported | | Create React App | ✅ Supported | | Astro | ✅ Supported | | Remix | ✅ Supported | | TanStack Start | ✅ Supported |

📄 License

MIT © MnhTng

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📝 Changelog

See GitHub Releases for changelog.