BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/Roi UI/chart-tailwind

Chart (Tailwind)

roi-ui/chart-tailwind
FreeItem

Composable chart components for building any type of data visualization with Recharts primitives.

Install it

npx shadcn@latest add https://roiui.com/r/chart-tailwind.json

Source

registry/brook/tailwind/ui/chart.tsxroiui.com/r/chart-tailwind.json · first 6 KB
1"use client";
2
3import {
4 type ComponentProps,
5 type ComponentType,
6 type CSSProperties,
7 createContext,
8 type ReactNode,
9 useContext,
10 useId,
11 useMemo,
12} from "react";
13import { Legend, ResponsiveContainer, Tooltip } from "recharts";
14import { cn } from "@/lib/utils";
15
16const THEMES = { light: "", dark: ".dark" } as const;
17
18export type ChartConfig = {
19 [k in string]: {
20 label?: ReactNode;
21 icon?: ComponentType;
22 } & ({ color?: string; theme?: never } | { color?: never; theme: Record<keyof typeof THEMES, string> });
23};
24
25type ChartContextProps = {
26 config: ChartConfig;
27};
28
29const ChartContext = createContext<ChartContextProps | null>(null);
30
31function useChart() {
32 const context = useContext(ChartContext);
33
34 if (!context) {
35 throw new Error("useChart must be used within a <ChartContainer />");
36 }
37
38 return context;
39}
40
41function ChartContainer({
42 id,
43 className,
44 children,
45 config,
46 ...props
47}: ComponentProps<"div"> & {
48 config: ChartConfig;
49 children: ComponentProps<typeof ResponsiveContainer>["children"];
50}) {
51 const uniqueId = useId();
52 const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`;
53
54 return (
55 <ChartContext.Provider value={{ config }}>
56 <div
57 {...props}
58 className={cn("flex h-full w-full justify-center text-xs", className)}
59 data-chart={chartId}
60 data-slot="chart"
61 >
62 <ChartStyle config={config} id={chartId} />
63 <ResponsiveContainer>{children}</ResponsiveContainer>
64 <style global jsx>{`
65 [data-chart="${chartId}"] .recharts-cartesian-axis-tick text {
66 fill: var(--muted-foreground);
67 }
68 [data-chart="${chartId}"] .recharts-cartesian-grid line {
69 stroke: oklch(from var(--border) l c h / 0.3);
70 }
71 [data-chart="${chartId}"] .recharts-curve.recharts-tooltip-cursor {
72 stroke: var(--border);
73 }
74 [data-chart="${chartId}"] .recharts-polar-grid line {
75 stroke: var(--border);
76 }
77 [data-chart="${chartId}"] .recharts-radial-bar-background-sector {
78 fill: var(--muted);
79 }
80 [data-chart="${chartId}"] .recharts-rectangle.recharts-tooltip-cursor {
81 fill: var(--muted);
82 opacity: 0.3;
83 }
84 [data-chart="${chartId}"] .recharts-reference-line line {
85 stroke: var(--border);
86 }
87 [data-chart="${chartId}"] .recharts-dot[stroke="#fff"] {
88// … truncated

What it pulls in

npm packages

  • recharts

Files it writes

  • registry/brook/tailwind/ui/chart.tsx

Facts

Registry
Roi UI
Type
registry:item
Access
Free
Files written
1
Licence
the repository states none
First indexed
2026-08-03
Last confirmed
yesterday

Go to the source

roiui.com preetecool/roi-ui on GitHub Raw registry item This item as JSON

More from Roi UI

All 123 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
AccordionaccordionRoi UIOtherFreeno deps · 2 files
Accordion (Tailwind)accordion-tailwindRoi UIOtherFreeno deps
AI Chatai-chatRoi UIOtherFreeno deps · 2 files
AI Chat (Tailwind)ai-chat-tailwindRoi UIOtherFreeno deps
AlertalertRoi UIOtherFree1 dep · 2 files
Alert Dialogalert-dialogRoi UIOtherFreeno deps · 2 files
Alert Dialog (Tailwind)alert-dialog-tailwindRoi UIOtherFreeno deps
Alert (Tailwind)alert-tailwindRoi UIOtherFree1 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