BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/amarjay-ui/chart

chart

amarjay-ui/chart
FreeComponent

Composable chart primitives built on Recharts.

Live preview

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

Install it

npx shadcn@latest add https://ui.amarjay.com/r/chart.json

Source

src/components/ui/chart.tsxui.amarjay.com/r/chart.json · first 6 KB
1"use client"
2
3import * as React from "react"
4import * as RechartsPrimitive from "recharts"
5import type { TooltipValueType } from "recharts"
6
7import { cn } from "@/lib/utils"
8
9// Format: { THEME_NAME: CSS_SELECTOR }
10const THEMES = { light: "", dark: ".dark" } as const
11
12const INITIAL_DIMENSION = { width: 320, height: 200 } as const
13type TooltipNameType = number | string
14
15export type ChartConfig = Record<
16 string,
17 {
18 label?: React.ReactNode
19 icon?: React.ComponentType
20 } & (
21 | { color?: string; theme?: never }
22 | { color?: never; theme: Record<keyof typeof THEMES, string> }
23 )
24>
25
26type ChartContextProps = {
27 config: ChartConfig
28}
29
30const ChartContext = React.createContext<ChartContextProps | null>(null)
31
32function useChart() {
33 const context = React.useContext(ChartContext)
34
35 if (!context) {
36 throw new Error("useChart must be used within a <ChartContainer />")
37 }
38
39 return context
40}
41
42function ChartContainer({
43 id,
44 className,
45 children,
46 config,
47 initialDimension = INITIAL_DIMENSION,
48 ...props
49}: React.ComponentProps<"div"> & {
50 config: ChartConfig
51 children: React.ComponentProps<
52 typeof RechartsPrimitive.ResponsiveContainer
53 >["children"]
54 initialDimension?: {
55 width: number
56 height: number
57 }
58}) {
59 const uniqueId = React.useId()
60 const chartId = `chart-${id ?? uniqueId.replace(/:/g, "")}`
61
62 return (
63 <ChartContext.Provider value={{ config }}>
64 <div
65 data-slot="chart"
66 data-chart={chartId}
67 className={cn(
68 "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-hidden [&_.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]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden",
69 className
70 )}
71 {...props}
72 >
73 <ChartStyle id={chartId} config={config} />
74 <RechartsPrimitive.ResponsiveContainer
75 initialDimension={initialDimension}
76 >
77 {children}
78 </RechartsPrimitive.ResponsiveContainer>
79 </div>
80// … truncated

What it pulls in

npm packages

  • recharts

Other registry items

  • utils

Files it writes

  • src/components/ui/chart.tsx

Facts

Registry
amarjay-ui
Type
registry:ui
Access
Free
Files written
1
Licence
the repository states none
First indexed
2026-08-08
Last confirmed
yesterday

Go to the source

Docs on amarjay-ui ui.amarjay.com amar-jay/ui on GitHub Raw registry item This item as JSON

More from amarjay-ui

All 18 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
alertalertamarjay-uiComponentsFree1 dep
avataravataramarjay-uiComponentsFree1 dep
badgebadgeamarjay-uiComponentsFree2 deps
buttonbuttonamarjay-uiComponentsFree2 deps
cardcardamarjay-uiComponentsFreeno deps
context-menucontext-menuamarjay-uiComponentsFree2 deps
dialogdialogamarjay-uiComponentsFree2 deps
dropdown-menudropdown-menuamarjay-uiComponentsFree2 deps
BlockDex

Built by

Kynth Studios

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 Studios

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 Studios

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