Day grid
Days as slanted-pixel dots sized by value.
Demo
Usage
import { DayGrid, type DayGridDatum } from '@tuttn/slant'
const data: DayGridDatum[] = [{ date: '2026-10-05', value: 4 }, { date: '2026-10-06', value: 1 }, /* … */]
// Uncontrolled: the grid keeps its own selected day. The range runs from the
// data's first date to its last unless start and end say otherwise.
<DayGrid data={data} label="Sessions per day" />
// Controlled, with a formatted value, a fixed range and a Sunday-first week.
const [day, setDay] = useState<string | null>(null)
<DayGrid data={data} label="Focus hours per day" value={day} onValueChange={setDay}
start="2026-07-01" end="2026-10-31" weekStart={0} format={hours => `${hours} h`} tone="success" />
// Your own summary under the grid, or false to keep the default for screen readers only.
<DayGrid data={data} label="Deploys per day" summary={<>Busiest day: <strong>Mon 12 Oct</strong></>} />
<DayGrid data={data} label="Deploys per day" summary={false} />Props
| Prop | Type | Default | Description |
|---|---|---|---|
data | readonly DayGridDatum[] | — | One entry per day with something to show, in any order. Days in the range without an entry are quiet. |
start | string | the data's first date | The first day drawn, as `YYYY-MM-DD`. Days before it in its week are empty cells. |
end | string | the data's last date | The last day drawn, as `YYYY-MM-DD`. Days after it in its week are empty cells; a start after the end draws no days. |
label | string | — | The grid's accessible name, e.g. "Sessions per day". |
format | (value: number) => string | String | Formats a value for each day's name, the tooltip and the summary's total. |
max | number | the largest value in the range | The value that draws the largest dot; anything above it draws the same. Dots are sized by the square root of `value / max`, so their area follows the value. |
weekStart | 0 | 1 | 1 | The weekday on the top row: 1 for Monday, 0 for Sunday. |
locale | string | 'en-GB' | For the dates in each day's name, the weekday and the month labels. |
tone | Tone | 'accent' | The colour of the dots for active days. |
value | string | null | — | The selected day, `YYYY-MM-DD`, or null for none. Pass it to control the selection; leave it out to let the grid keep its own. |
defaultValue | string | null | null | The day an uncontrolled grid starts with selected. |
onValueChange | (date: string) => void | — | Called with the day, `YYYY-MM-DD`, that a click, Enter or Space selects. |
summary | ReactNode | false | messages.dayGridSummary: the total, the active days and the days in the range | The text under the grid, which is also its accessible description. `false` keeps the default for screen readers only. |
…rest | HTMLAttributes<HTMLDivElement> | — | className, style, other attributes and the ref go on the root, which holds the grid and its summary. |
Reading it
Each column is a week and each row a weekday, starting from weekStart. A day's dot is a slanted pixel whose side grows with the square root of value / max, so its area follows the value; a quiet day keeps a small, faint dot. Days before start and after end are empty cells. Dates are read and drawn in UTC, so a YYYY-MM-DD never shifts a day in another time zone, and the server and the browser agree.
Keyboard
The grid is one tab stop: the selected day, or else the last day. Up and Down move a day, Left and Right a week (they swap under right-to-left text, where the weeks run from the right), Home and End go to the ends of that week, Page Up and Page Down four weeks, and Ctrl+Home and Ctrl+End the first and last day. Movement stops at the ends of the range. Enter, Space or a click selects the day and calls onValueChange with its date.
Accessibility
The grid is named by label and described by the summary under it, messages.dayGridSummary by default (for example "612 in total, on 98 of 140 days."); summary replaces it, and false keeps it for screen readers only. Every row is headed by its weekday, every day is named with its date and value ("Mon, 5 Oct 2026: 4", dates by locale and values by format), and the selected day has aria-selected. The month labels and the hover tooltip are visual only, since the names already carry them.
Motion
Nothing animates on its own, so there is nothing to pause off screen. Dots ease to a new size when the data changes and grow a little under the pointer; under reduced motion they change at once. A range wider than its container scrolls and opens on its latest weeks. See also Calendar for picking dates and Bar chart for values over time.