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

yyc3-knowledge-base/chart
UnverifiedComponent

shadcn/ui publishes no description for this item.

Install it

npx shadcn@latest add https://raw.githubusercontent.com/YYC-Cube/YYC3-Knowledge-Base/main/YYC3-D/ui/apps/v4/chart.json

Source

registry/new-york-v4/ui/chart.tsxraw.githubusercontent.com/YYC-Cube/YYC3-Knowledge-Base/main/YYC3-D/ui/apps/v4/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/new-york-v4/ui/chart.tsx

Facts

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

Go to the source

ui.shadcn.com YYC-Cube/YYC3-Knowledge-Base on GitHub Raw registry item This item as JSON

More from shadcn/ui

All 411 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
accordionaccordionshadcn/uiComponentsUnverified1 dep
alertalertshadcn/uiComponentsUnverifiedno deps
alert-dialogalert-dialogshadcn/uiComponentsUnverified1 dep
aspect-ratioaspect-ratioshadcn/uiComponentsUnverified1 dep
avataravatarshadcn/uiComponentsUnverified1 dep
badgebadgeshadcn/uiComponentsUnverified1 dep
breadcrumbbreadcrumbshadcn/uiComponentsUnverified1 dep
buttonbuttonshadcn/uiComponentsUnverified1 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