Chart
boldkit/chartFreeComponent
Beautiful charts with neubrutalism styling built on Recharts
Live preview
live · rendered by the registry
Rendered by boldkit on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://boldkit.dev/r/chart.jsonSource
1import * as React from 'react'2import * as RechartsPrimitive from 'recharts'3import { cva, type VariantProps } from 'class-variance-authority'4import { cn, sanitizeCssValue } from '@/lib/utils'56// Format: { THEME_NAME: CSS_SELECTOR }7const THEMES = { light: '', dark: '.dark' } as const89// Neubrutalism color palettes for charts10export const CHART_PALETTES = {11 bold: [12 'hsl(var(--primary))',13 'hsl(var(--secondary))',14 'hsl(var(--accent))',15 'hsl(var(--success))',16 'hsl(var(--warning))',17 'hsl(var(--info))',18 ],19 vibrant: [20 'hsl(0 84% 60%)', // Coral red21 'hsl(174 62% 50%)', // Teal22 'hsl(49 100% 60%)', // Yellow23 'hsl(280 65% 60%)', // Purple24 'hsl(145 63% 49%)', // Green25 'hsl(212 100% 60%)', // Blue26 ],27 pastel: [28 'hsl(0 84% 75%)', // Light coral29 'hsl(174 62% 70%)', // Light teal30 'hsl(49 100% 75%)', // Light yellow31 'hsl(280 65% 75%)', // Light purple32 'hsl(145 63% 70%)', // Light green33 'hsl(212 100% 75%)', // Light blue34 ],35 monochrome: [36 'hsl(var(--foreground))',37 'hsl(var(--foreground) / 0.8)',38 'hsl(var(--foreground) / 0.6)',39 'hsl(var(--foreground) / 0.4)',40 'hsl(var(--foreground) / 0.2)',41 'hsl(var(--foreground) / 0.1)',42 ],43} as const4445export type ChartPalette = keyof typeof CHART_PALETTES4647// Helper to get colors from a palette48export function getChartColor(palette: ChartPalette, index: number): string {49 const colors = CHART_PALETTES[palette]50 return colors[index % colors.length]51}5253// Generate ChartConfig from palette54export function createChartConfig(55 keys: string[],56 labels: string[],57 palette: ChartPalette = 'bold'58): ChartConfig {59 const config: ChartConfig = {}60 keys.forEach((key, index) => {61 config[key] = {62 label: labels[index] || key,63 color: getChartColor(palette, index),64 }65 })66 return config67}6869export type ChartConfig = {70 [k in string]: {71 label?: React.ReactNode72 icon?: React.ComponentType73 } & (74 | { color?: string; theme?: never }75 | { color?: never; theme: Record<keyof typeof THEMES, string> }76 )77}7879type ChartContextProps = {80 config: ChartConfig81}8283const ChartContext = React.createContext<ChartContextProps | null>(null)8485function useChart() {86 const context = React.useContext(ChartContext)8788 if (!context) {89 throw new Error('useChart must be used within a <ChartContainer />')90 }9192 return context93}9495const chartContainerVariants = cva(96// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from boldkit
All 94 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | boldkit | Components | Free | 2 deps | |
| Alertalert | boldkit | Components | Free | 2 deps | |
| Alert Dialogalert-dialog | boldkit | Components | Free | 1 dep | |
| ASCII Shapesascii-shapes | boldkit | Components | Free | no deps | |
| Aspect Ratioaspect-ratio | boldkit | Components | Free | 1 dep | |
| Avataravatar | boldkit | Components | Free | 1 dep | |
| Badgebadge | boldkit | Components | Free | 1 dep | |
| Breadcrumbbreadcrumb | boldkit | Components | Free | 2 deps |
