BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/boldkit/heatmap-chart

Heatmap Chart

boldkit/heatmap-chart
FreeComponent

Heatmap grid for correlation and intensity data - custom CSS Grid implementation

Live preview

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

Install it

npx shadcn@latest add https://boldkit.dev/r/heatmap-chart.json

Source

registry/default/ui/heatmap-chart.tsxboldkit.dev/r/heatmap-chart.json · first 6 KB
1import * as React from 'react'
2import { cn } from '@/lib/utils'
3import { ChartEmpty } from './chart'
4
5export interface HeatmapCellData {
6 row: string
7 col: string
8 value: number
9}
10
11export interface HeatmapChartProps extends React.HTMLAttributes<HTMLDivElement> {
12 data: HeatmapCellData[]
13 rows: string[]
14 cols: string[]
15 /** CSS color at 0 intensity (default: transparent primary) */
16 colorLow?: string
17 /** CSS color at max intensity (default: primary) */
18 colorHigh?: string
19 showLabels?: boolean
20 showTooltip?: boolean
21 cellSize?: number
22 /** Accessible label for screen readers (default: "Heatmap chart") */
23 ariaLabel?: string
24 /** Fires when a cell is clicked or activated via keyboard (Enter/Space). */
25 onCellClick?: (cell: HeatmapCellData) => void
26 emptyState?: React.ReactNode
27}
28
29function interpolateOpacity(value: number, min: number, max: number): number {
30 if (max === min) return 0.5
31 return (value - min) / (max - min)
32}
33
34/**
35 * Compute cell background color from colorLow → colorHigh using CSS color-mix(),
36 * which works with any valid CSS color string including hsl(var(--*)) tokens.
37 * Falls back to primary-opacity when custom colors are not provided.
38 */
39function getCellColor(
40 intensity: number,
41 colorLow: string | undefined,
42 colorHigh: string | undefined
43): string {
44 if (colorLow && colorHigh) {
45 // color-mix interpolates in srgb space: at t=0 we want colorLow, at t=1 we want colorHigh.
46 // color-mix(in srgb, colorHigh <t*100>%, colorLow) gives us colorHigh at t=1 and colorLow at t=0.
47 const pct = Math.round(Math.max(0, Math.min(1, intensity)) * 100)
48 return `color-mix(in srgb, ${colorHigh} ${pct}%, ${colorLow})`
49 }
50 // Default: vary opacity of primary from 0.08 (low) to 1 (high)
51 return `hsl(var(--primary) / ${Math.max(0.08, intensity)})`
52}
53
54const HeatmapChart = React.forwardRef<HTMLDivElement, HeatmapChartProps>(
55 (
56 {
57 data,
58 rows,
59 cols,
60 colorLow,
61 colorHigh,
62 showLabels = true,
63 showTooltip = true,
64 cellSize = 40,
65 ariaLabel = 'Heatmap chart',
66 onCellClick,
67 emptyState,
68 className,
69 ...props
70 },
71 ref
72 ) => {
73 const [tooltip, setTooltip] = React.useState<{ x: number; y: number; row: string; col: string; value: number } | null>(null)
74 const isInteractive = !!onCellClick
75 const cellTabIndex = showTooltip || isInteractive ? 0 : undefined
76
77 const valueMap = React.useMemo(() => {
78 const map = new Map<string, number>()
79// … truncated

What it pulls in

Other registry items

  • @boldkit/utils
  • @boldkit/chart

Files it writes

  • registry/default/ui/heatmap-chart.tsx

Facts

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

Go to the source

Docs on boldkit boldkit.dev ANIBIT14/boldkit on GitHub Raw registry item This item as JSON

More from boldkit

All 94 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
AccordionaccordionboldkitComponentsFree2 deps
AlertalertboldkitComponentsFree2 deps
Alert Dialogalert-dialogboldkitComponentsFree1 dep
ASCII Shapesascii-shapesboldkitComponentsFreeno deps
Aspect Ratioaspect-ratioboldkitComponentsFree1 dep
AvataravatarboldkitComponentsFree1 dep
BadgebadgeboldkitComponentsFree1 dep
BreadcrumbbreadcrumbboldkitComponentsFree2 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