Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Heatmap Pivot Table Block for React

A regional revenue pivot of five regions by four quarters with row and column totals, shaded in five solid steps against the whole table, each row or each column, with the highest cell outlined and a legend.

Framework
UI library

Preview

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Overview

Show where the numbers are high and low without hiding any of them, with this heatmap pivot table for React with Base UI. A compact header holds a Toggle Group named "Shade by" with Whole table, Each row and Each column. Inside a hairline frame with a plus mark on each corner, a band names the table and says in words how it is shaded, over a native table of Cellshade's revenue in thousands of dollars: five regions down the side, four fiscal quarters across, a total at the end of every row and under every column. Each cell takes one of five solid steps of the text colour and the darkest steps turn their figure to the background colour, so the contrast holds in both themes. Choosing a scope rescales the steps: one scale for all twenty cells, each region against its own quarters, or each quarter against its regions. The highest cell of the scale is outlined, a legend under the table says what light and dark mean, and every figure stays printed, so the shade is never the only signal. It is built from Toggle Group and Guides, with a CSS entrance only. For sales pivots, cohort tables, scorecards and any grid where the eye needs a nudge.

FAQ

What does the shading scope change?

It changes which numbers a cell is measured against, never the numbers. With Whole table the lowest of the twenty cells is the lightest and the highest the darkest. With Each row every region gets its own scale, so a small region's best quarter is as dark as a big region's. With Each column every quarter compares its five regions. A cell's step comes from where its figure falls between the lowest and highest of its scope, split into five equal bands by stepOf.

How do I use my own rows and columns?

Edit REGIONS (a name and one revenue figure per quarter) and QUARTERS. Totals, shading and the outlined cell are all worked out from those numbers, so nothing else needs changing. The five steps are literal class names in STEPS, which keeps them visible to Tailwind; the last one carries text-background so its figure stays readable. For another kind of figure, change money and the caption.

Why is the shading grey and not a colour ramp?

The steps are mixes of the text colour, so they follow the theme and keep their contrast in light and dark without a second palette. Colour alone also fails for people who cannot tell the steps apart, so the figures are always printed and the highest cell of the scope has an outline, which does not depend on colour at all.

What stays local, and how do I wire it to real data?

The data is a constant and the scope lives in one useState; nothing is requested or saved. To feed it real figures, build REGIONS from your API in the page and pass it in, or fetch it where you render the block. Totals and shading are derived on every render, so nothing needs to be kept in step.

Is a shaded table accessible?

Yes. It is a native table with a caption, th scope="col" heads and a row header for each region, so a screen reader reads each figure with its region and quarter. The shading is decoration, the legend and outline are for sighted users, and the toggle is a labelled group of buttons that follows the arrow keys. A polite line says which scope is active whenever you change it. The table region is focusable so it can be scrolled by keyboard on a very narrow screen.

How does it look on a phone?

All six columns stay, with tighter padding and smaller figures, and nothing scrolls sideways at 320 pixels; region names wrap. The scope control sits full width under the sentence. The block keeps its size in every scope, so switching never moves the table.

  • Pro

    A survey crosstab of answers by plan (Free, Pro, Team, All) with n shown on each column, a mode toggle for column percent, row percent or counts, a question menu for three questions and four solid shading steps.

  • Pro

    Baseline Comparison Table

    Totals and comparison

    Five camera bodies compared against one you pick: every figure shows its own value and, under it, a signed difference or Same or Different against the baseline, with sticky spec names and grouped rows.

  • Pro

    A hire quote whose footer works down from the subtotal through a percentage discount, a tax rate, a flat delivery charge and the total, each showing its formula.

  • Pro

    A project table whose categories are marked by shape, weight and word, never colour: a circle, square, diamond and triangle in foreground weights, and a legend of toggle chips with counts that dims the other categories.

  • Pro

    A twelve-week by seven-day commit heatmap whose five-step legend is a set of toggles: choosing a level keeps only those days at full strength, outlines the rest and counts the days.

  • Pro

    Sortable Members Table

    Sort and search

    A members table whose column heads are buttons: press one to sort, again to reverse, a third time for the original order, with aria-sort on the active head, ties settled by name and a spoken line for each result.