Heatmap
A heatmap component to visualize data density over time.
Note: The Heatmap is a fully custom component with no external dependencies — built as a self-contained JavaScript component exposed through a Python API for use in Reflex.
Installation
Copy the following code into your app directory.
Command
Command
Manual
Manual
uv
Anatomy
Use the following composition to build a Heatmap component.
Examples
GitHub-Style HeatMap
Classic GitHub contribution graph — discrete mode, default green scale.
Interpolated HeatMap
Set the interpolation prop to linear and pass in custom colors for continuous data visualization.
Square Root HeatMap
Set the interpolation prop to sqrt and pass in custom colors. sqrt scaling makes low values more visible — good when most activity is sparse.
Discrete Color Mode
Set the color_mode prop to discrete with a custom 5-level purple color scale. Pass any list of hex colors to color_scale — more levels = finer granularity.
Cell Size
Set the cell_size prop to a number to change cell size. Setting the interpolation to log is ideal when a few extreme values dominate — compresses the high end.
Minimal HeatMap
Set the show_dow and show_months props to False and lower the cell_size to get a compact, minimal heatmap. Useful as a sparkline-style indicator embedded in a dashboard card.
API Reference
Props
Data format
python
Dates must be strings in YYYY-MM-DD format. Values must be non-negative integers. Dates outside the start_date/end_date range are ignored. Dates within the range that are missing from data render as empty cells using var(--secondary).
Color Modes
Discrete
Values are bucketed into len(color_scale) levels using a linear scale from 0 to max(value). The default scale is a 5-level GitHub-style green:
python
Pass any number of hex strings to customize. More levels give finer granularity.
Interpolate
Colors are blended smoothly between min_color and max_color using the chosen interpolation function. Zero-value cells always use var(--secondary) regardless of min_color.