Chart
neobrutalism-components/chartFreeComponent
Neobrutalism Components publishes no description for this item.
Live preview
live · rendered by the registry
Rendered by Neobrutalism Components on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://www.neobrutalism.dev/r/chart.jsonSource
1"use client"23import * as RechartsPrimitive from "recharts"45import * as React from "react"67import { cn } from "@/lib/utils"89// Format: { THEME_NAME: CSS_SELECTOR }10const THEMES = { light: "", dark: ".dark" } as const1112export type ChartConfig = {13 [k in string]: {14 label?: React.ReactNode15 icon?: React.ComponentType16 } & (17 | { color?: string; theme?: never }18 | { color?: never; theme: Record<keyof typeof THEMES, string> }19 )20}2122type ChartContextProps = {23 config: ChartConfig24}2526const ChartContext = React.createContext<ChartContextProps | null>(null)2728function useChart() {29 const context = React.useContext(ChartContext)3031 if (!context) {32 throw new Error("useChart must be used within a <ChartContainer />")33 }3435 return context36}3738function ChartContainer({39 id,40 className,41 children,42 config,43 ...props44}: React.ComponentProps<"div"> & {45 config: ChartConfig46 children: React.ComponentProps<47 typeof RechartsPrimitive.ResponsiveContainer48 >["children"]49}) {50 const uniqueId = React.useId()51 const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`5253 return (54 <ChartContext.Provider value={{ config }}>55 <div56 data-slot="chart"57 data-chart={chartId}58 className={cn(59 "[&_.recharts-cartesian-axis-tick_text]:fill-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-[#80808080] [&_.recharts-curve.recharts-tooltip-cursor]:stroke-[#80808080] [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-black [&_.recharts-polar-grid_[stroke='#ccc']]:dark:stroke-white [&_.recharts-reference-line_[stroke='#ccc']]:stroke-black [&_.recharts-reference-line_[stroke='#ccc']]:dark:stroke-white flex aspect-video justify-center text-xs [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-border [&_.recharts-surface]:outline-hidden",60 "[&_.recharts-layer_path]:[fill-opacity:1] [&_.recharts-layer_path]:[stroke-width:2] [&_.recharts-layer_path]:[stroke:var(--color-border)]",61 className,62 )}63 {...props}64 >65 <ChartStyle id={chartId} config={config} />66 <RechartsPrimitive.ResponsiveContainer>67 {children}68 </RechartsPrimitive.ResponsiveContainer>69 </div>70 </ChartContext.Provider>71 )72}7374const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {75// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from Neobrutalism Components
All 92 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | Neobrutalism Components | Components | Free | 1 dep | |
| Alertalert | Neobrutalism Components | Components | Free | no deps | |
| Alert dialogalert-dialog | Neobrutalism Components | Components | Free | 1 dep | |
| Avataravatar | Neobrutalism Components | Components | Free | 1 dep | |
| Badgebadge | Neobrutalism Components | Components | Free | no deps | |
| Breadcrumbbreadcrumb | Neobrutalism Components | Components | Free | 1 dep | |
| Buttonbutton | Neobrutalism Components | Components | Free | 1 dep | |
| Calendarcalendar | Neobrutalism Components | Components | Free | 2 deps |
