Skip to content
IndexRequest a UIAboutContact

Heatmap Calendar

A grid of days shaded by activity, with a tooltip and arrow-key navigation.

Open alone ↗

AI prompt

PROMPT: PASTE INTO YOUR AI CODING TOOL
Build a heatmap of 12 weeks by 7 days (84 cells) laid out as a CSS grid with grid-auto-flow column and 7 rows, cell size about 18px with 3px gaps and 4px radius. Generate deterministic activity counts from 0 to 12 and map them to five shades from #ebebe7 to #171717 (levels 0 to 4). A legend row "Less" to "More" shows the five shades. Hovering a cell shows a tooltip "N contributions on Mon, 14 Apr" and a 2px dark outline. The grid is a single tab stop with role grid semantics: arrow keys move the active cell, Home and End go to the first and last cell of the row, and aria-activedescendant points at the active cell; each cell has an aria-label with the date and count. On load fade the cells in column by column with a 12ms stagger over 500ms. Under prefers-reduced-motion skip the fade.

About this pattern

Definition

Each cell is one day, arranged in weekly columns. Darker cells mean more activity. Hovering a cell shows the date and count.

Purpose & UX principles

  • Reveals rhythm and gaps over months at a glance.
  • Intensity uses five lightness steps with a legend, and each cell has a text label, so it is not colour only.
  • With 84 cells a tab stop each would be hostile: the grid is one tab stop with arrow-key navigation.

Interaction states

  • Level 0 to 4, hovered cell (outline), keyboard-active cell (outline and tooltip).

Motion specification

  • Cells fade in column by column over 500ms with a 12ms stagger.
  • Hover outline appears in 100ms.
  • Reduced motion: no fade-in.

Responsive behaviour

  • Cells size to the container width; the grid never scrolls horizontally at phone widths.
  • Touch: tapping a cell shows its tooltip.

Code

HTML
<div class="box">
  <div class="hm" id="hm" role="grid" tabindex="0" aria-label="Activity over the last 12 weeks. Use arrow keys."></div>
  <div class="foot"><span id="tip" aria-live="polite">Hover or use arrow keys</span><span class="lg">Less <i style="background:#ebebe7"></i><i style="background:#c8c8c3"></i><i style="background:#8c8c87"></i><i style="background:#4a4a47"></i><i style="background:#171717"></i> More</span></div>
</div>

Related patterns

Interactive Bar Chart

↗
Interactive Bar ChartData Visualization

Sparkline Trend Rows

↗
Sparkline Trend RowsData Visualization

Donut Chart with Linked Legend

↗
Donut Chart with Linked LegendData Visualization