BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/bklit-ui/bar-chart

Bar Chart

bklit-ui/bar-chart
FreeComponent

A composable bar chart with horizontal/vertical orientations and animations

Install it

npx shadcn@latest add https://bklit.com/r/bar-chart.json

Source

src/charts/bar-chart.tsxbklit.com/r/bar-chart.json · first 6 KB
1"use client";
2
3import { localPoint } from "@visx/event";
4import { ParentSize } from "@visx/responsive";
5import { scaleBand, scaleLinear } from "@visx/scale";
6import type { Transition } from "motion/react";
7import {
8 memo,
9 type ReactElement,
10 type ReactNode,
11 useCallback,
12 useEffect,
13 useMemo,
14 useRef,
15 useState,
16} from "react";
17import { cn } from "@/lib/utils";
18import { DEFAULT_ANIMATION_EASING } from "./animation";
19import type { BarProps } from "./bar";
20import { topSquareCenterY } from "./bar-squares-layout";
21import {
22 forEachChartChild,
23 isChartClipPassthrough,
24 isClipExcludedComponent,
25 isPostOverlayComponent,
26 isUnderlayComponent,
27 renderKeyedChartLayers,
28 resolveChartChildElement,
29} from "./chart-child-passthrough";
30import {
31 ChartProvider,
32 type LineConfig,
33 type Margin,
34 type TooltipData,
35} from "./chart-context";
36import { isGradientDefComponent, isPatternDefComponent } from "./chart-defs";
37import { shortDateFmt } from "./chart-formatters";
38import {
39 type ChartPhase,
40 type ChartStatus,
41 DEFAULT_CHART_LIFECYCLE,
42 resolveRestingChartPhase,
43} from "./chart-phase";
44import { BarLoadingSkeleton } from "./loading-sweep";
45import { extractReferenceAreaConfigs } from "./reference-area-config";
46import { useScheduledTooltip } from "./use-scheduled-tooltip";
47import {
48 buildYScalesForLines,
49 getPrimaryYScale,
50 normalizeYAxisId,
51 wrapSingleYScale,
52} from "./y-axis-scales";
53
54/** Skeleton bars to show when `status="loading"` and `data` is empty. */
55const FALLBACK_LOADING_BARS = 12;
56
57export type BarOrientation = "vertical" | "horizontal";
58
59export interface BarChartProps {
60 /** Data array - each item should have an x-axis key and numeric values */
61 data: Record<string, unknown>[];
62 /** Key in data for the categorical axis. Default: "name" */
63 xDataKey?: string;
64 /** Chart margins */
65 margin?: Partial<Margin>;
66 /** Animation duration in milliseconds. Default: 1100 */
67 animationDuration?: number;
68 /** CSS easing for bar grow transitions. */
69 animationEasing?: string;
70 /** Motion enter transition (spring or cubic-bezier tween). */
71 enterTransition?: Transition;
72 /** Signature of motion URL state — triggers enter replay when it changes. */
73 revealSignature?: string;
74 /** Aspect ratio as "width / height". Default: "2 / 1" */
75 aspectRatio?: string;
76 /** Additional class name for the container */
77 className?: string;
78 /** Gap between bar groups as a fraction of band width (0-1). Default: 0.2 */
79 barGap?: number;
80// … truncated

What it pulls in

npm packages

  • @visx/gradient@4.0.1-alpha.0
  • @visx/pattern@4.0.1-alpha.0
  • @visx/shape@4.0.1-alpha.0
  • motion

Other registry items

  • @bklit/chart-context
  • @bklit/chart-animation
  • @bklit/grid
  • @bklit/chart-tooltip
  • @bklit/utils

Files it writes

  • src/charts/bar-chart.tsx
  • src/charts/chart-child-passthrough.ts
  • src/charts/chart-legend-hover.tsx
  • src/charts/bar.tsx
  • src/charts/bar-squares.tsx
  • src/charts/bar-squares-layout.ts
  • src/charts/pattern-preset.tsx
  • src/charts/visx-pattern.tsx
  • src/charts/bar-depth-geometry.ts
  • src/charts/bar-x-axis.tsx
  • src/charts/bar-y-axis.tsx
  • src/charts/loading-sweep.tsx
  • src/charts/bar-chart-loading.tsx

Facts

Registry
bklit-ui
Type
registry:component
Access
Free
Files written
13
Licence
MIT
First indexed
2026-08-03
Last confirmed
yesterday

Go to the source

bklit.com bklit/bklit-ui on GitHub Raw registry item This item as JSON

More from bklit-ui

All 56 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Area Chartarea-chartbklit-uiComponentsFree4 deps · 14 files
Chart Backgroundbackgroundbklit-uiComponentsFree2 deps · 3 files
Bar Depthbar-depthbklit-uiComponentsFree1 dep
Candlestick Chartcandlestick-chartbklit-uiComponentsFree4 deps · 4 files
Chart Animationchart-animationbklit-uiComponentsFree1 dep · 7 files
Chart Contextchart-contextbklit-uiComponentsFree5 deps · 12 files
Chart Series Layerchart-seriesbklit-uiComponentsFree3 deps · 15 files
Chart Stat Flowchart-stat-flowbklit-uiComponentsFree2 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