Heatmap

Activity per day over months, like a contribution calendar. Every day is a keyboard-reachable cell with a tooltip.

Status: beta. Category: Data display.

import { Heatmap } from '@glyphui/ui/chart'

Exports: Heatmap.

Notes

  • Tab moves into the grid once; the arrow keys move by day and week, Home and End jump to the first and last day.
  • Each cell is read as “12 deploys on Mon, Oct 6, 2026”. Set unit to name what is counted.
  • Busier days get stronger tints of one color, from the muted surface up to the full color.

Heatmap props

PropTypeDefaultDescription
data (required)readonly T[]One row per day. Missing days count as zero.
date (required)stringField holding the day: a Date, a timestamp or a YYYY-MM-DD string.
title (required)string
value (required)stringField holding the day's value.
classNamestring
colorChartColorValueDefault chart-1. Busier days get stronger tints of it.
descriptionReactNode
emptyReactNodeShown when there is no data. Defaults to a short "No data" message.
errorunknownShows an error message in place of the plot, with a retry button when onRetry is set.
fromDateFirst day shown. Defaults to 52 weeks before to.
hideTitleboolean
levelsnumberNumber of tint steps above zero. Default 4.
loadingbooleanShows a skeleton in place of the plot.
localestringLocale for month and day names. Defaults to the browser's.
onCellClick((date: Date, value: number) => void)
onRetry(() => unknown)
toDateLast day shown. Defaults to the latest day in data, or today.
unitstringNoun read after the value, e.g. "deploys" → "12 deploys on Mon, Oct 6".
valueFormatter((value: number) => string)
weekStart0 | 10 starts weeks on Sunday, 1 on Monday. Default 0.

Example: Deploys per day

A year of activity.

import { Heatmap } from '@glyphui/ui/chart'

// A year of deploys: busy mid-week, quiet weekends, a holiday freeze in late December.
const end = new Date(2026, 9, 16)
const data = Array.from({ length: 364 }, (_, i) => {
  const day = new Date(end.getFullYear(), end.getMonth(), end.getDate() - 363 + i)
  const weekday = day.getDay()
  const freeze = day.getMonth() === 11 && day.getDate() > 20
  const base = weekday === 0 || weekday === 6 ? 0.4 : 3 + ((i * 7919) % 5)
  return { day, deploys: freeze ? 0 : Math.max(0, Math.round(base + Math.sin(i / 9) * 2)) }
})

export default function Example() {
  return (
    <Heatmap
      className="w-full"
      title="Deploys per day"
      data={data}
      date="day"
      value="deploys"
      unit="deploys"
      to={end}
      locale="en-US"
    />
  )
}

Example: One quarter, Monday first

from, to and weekStart set the range; onCellClick opens a day.

import { Text } from '@glyphui/ui'
import { Heatmap } from '@glyphui/ui/chart'
import { useState } from 'react'

const data = Array.from({ length: 92 }, (_, i) => ({
  date: new Date(2026, 6, 1 + i),
  tickets: (i * 37) % 11,
}))

export default function Example() {
  const [picked, setPicked] = useState<string | null>(null)
  return (
    <div className="grid w-full gap-2">
      <Heatmap
        title="Support tickets, Q3"
        data={data}
        date="date"
        value="tickets"
        unit="tickets"
        from={new Date(2026, 6, 1)}
        to={new Date(2026, 8, 30)}
        weekStart={1}
        color="chart-2"
        locale="en-US"
        onCellClick={(date, value) =>
          setPicked(`${date.toLocaleDateString('en-US', { dateStyle: 'medium' })}: ${value}`)
        }
      />
      <Text size="small" tone="muted">
        {picked ? `Opened ${picked}` : 'Click a day or press Enter on it.'}
      </Text>
    </div>
  )
}

Live page: https://glyphui.xyz/components/heatmap