BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/blok/chart

Chart

blok/chart
FreeComponent

Beautiful charts. Built using Recharts.

Install it

npx shadcn@latest add https://blok.sitecore.com/r/chart.json

Source

src/components/ui/chart.tsxblok.sitecore.com/r/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
37function ChartContainer({
38 id,
39 className,
40 children,
41 config,
42 ...props
43}: React.ComponentProps<"div"> & {
44 config: ChartConfig;
45 children: React.ComponentProps<
46 typeof RechartsPrimitive.ResponsiveContainer
47 >["children"];
48}) {
49 const uniqueId = React.useId();
50 const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`;
51
52 return (
53 <ChartContext.Provider value={{ config }}>
54 <div
55 data-slot="chart"
56 data-chart={chartId}
57 role="img"
58 aria-label={props["aria-label"] || "Data visualization chart"}
59 className={cn(
60 "[&_.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-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 flex aspect-video justify-center text-xs [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden",
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}
73
74const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
75 const colorConfig = Object.entries(config).filter(
76 ([, config]) => config.theme || config.color,
77 );
78// … truncated

What it pulls in

npm packages

  • recharts@2.15.4

Other registry items

  • https://blok.sitecore.com/r/theme.json

Files it writes

  • src/components/ui/chart.tsx

Facts

Registry
blok
Type
registry:ui
Access
Free
Files written
1
Licence
NOASSERTION
First indexed
2026-08-03
Last confirmed
today

Go to the source

blok.sitecore.com Sitecore/blok on GitHub Raw registry item This item as JSON

More from blok

All 72 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
AccordionaccordionblokComponentsFree2 deps · 2 files
Action baraction-barblokComponentsFree1 dep · 2 files
AlertalertblokComponentsFree2 deps · 2 files
Alert dialogalert-dialogblokComponentsFree2 deps
Aspect ratioaspect-ratioblokComponentsFree1 dep
AvataravatarblokComponentsFree1 dep
BadgebadgeblokComponentsFree2 deps
All componentsblok-componentsblokComponentsFreeno deps
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