BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/shadcn/ui/chart

chart

accelya-ui-lib/chart
FreeComponent

shadcn/ui publishes no description for this item.

Live preview

live · rendered by the registry
Rendered by shadcn/ui on their own page — this is the component running, not a screenshot of it.

Install it

npx shadcn@latest add https://raw.githubusercontent.com/ramsaoji/Accelya-UI-Lib/main/public/r/styles/default/chart.json

Source

ui/chart.tsxraw.githubusercontent.com/ramsaoji/Accelya-UI-Lib/main/public/r/styles/default/chart.json · first 6 KB
1"use client"
2
3import * as React from "react"
4import * as RechartsPrimitive from "recharts"
5
6import { cn } from "@/lib/utils"
7
8// Format: { THEME_NAME: CSS_SELECTOR }
9const THEMES = { light: "", dark: ".dark" } as const
10
11export type ChartConfig = {
12 [k in string]: {
13 label?: React.ReactNode
14 icon?: React.ComponentType
15 } & (
16 | { color?: string; theme?: never }
17 | { color?: never; theme: Record<keyof typeof THEMES, string> }
18 )
19}
20
21type ChartContextProps = {
22 config: ChartConfig
23}
24
25const ChartContext = React.createContext<ChartContextProps | null>(null)
26
27function useChart() {
28 const context = React.useContext(ChartContext)
29
30 if (!context) {
31 throw new Error("useChart must be used within a <ChartContainer />")
32 }
33
34 return context
35}
36
37const ChartContainer = React.forwardRef<
38 HTMLDivElement,
39 React.ComponentProps<"div"> & {
40 config: ChartConfig
41 children: React.ComponentProps<
42 typeof RechartsPrimitive.ResponsiveContainer
43 >["children"]
44 }
45>(({ id, className, children, config, ...props }, ref) => {
46 const uniqueId = React.useId()
47 const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`
48
49 return (
50 <ChartContext.Provider value={{ config }}>
51 <div
52 data-chart={chartId}
53 ref={ref}
54 className={cn(
55 "flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none",
56 className
57 )}
58 {...props}
59 >
60 <ChartStyle id={chartId} config={config} />
61 <RechartsPrimitive.ResponsiveContainer>
62 {children}
63 </RechartsPrimitive.ResponsiveContainer>
64 </div>
65 </ChartContext.Provider>
66 )
67})
68ChartContainer.displayName = "Chart"
69
70const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
71 const colorConfig = Object.entries(config).filter(
72 ([, config]) => config.theme || config.color
73 )
74
75 if (!colorConfig.length) {
76// … truncated

What it pulls in

npm packages

  • recharts@2.15.4
  • lucide-react

Other registry items

  • card

Files it writes

  • registry/default/ui/chart.tsx

Facts

Registry
shadcn/ui
Type
registry:ui
Access
Free
Files written
1
Licence
the repository states none
First indexed
2026-08-01
Last confirmed
3 days ago

Go to the source

Docs on shadcn/ui ramsaoji/Accelya-UI-Lib on GitHub Raw registry item This item as JSON

More from shadcn/ui

All 357 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
accordionaccordionshadcn/uiComponentsFree1 dep
alertalertshadcn/uiComponentsFreeno deps
alert-dialogalert-dialogshadcn/uiComponentsFree1 dep
aspect-ratioaspect-ratioshadcn/uiComponentsFree1 dep
avataravatarshadcn/uiComponentsFree1 dep
badgebadgeshadcn/uiComponentsFree1 dep
breadcrumbbreadcrumbshadcn/uiComponentsFree1 dep
buttonbuttonshadcn/uiComponentsFree1 dep
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex