Shadcn Schedule Matrix Table
People down the side, days across the top and a shift in every cell. Assign with a click or the keyboard, and see short-staffed shifts, too little rest and overtime while you edit.
$ npx shadcn add https://www.shad-table.dev/r/schedule-matrix-table.jsonWard 4B · 23–29 November 2026
Click a cell to pick a shift, or move with the arrow keys and type its letter.
- Early 06:00–14:00
- Late 14:00–22:00
- Night 22:00–06:00
- Leave
| Staff | Mon23 | Tue24 | Wed25 | Thu26 | Fri27 | Sat28 | Sun29 | Hours |
|---|---|---|---|---|---|---|---|---|
Amara OkaforCharge nurse | 40 / 40hOn contract | |||||||
Luis HerreraNurse | 40 / 40hOn contract | |||||||
Hana SatoNurse | 24 / 24hOn contract | |||||||
Tom BeckerNurse | 24 / 40h16h free | |||||||
Priya NairNurse | 24 / 24hOn contract | |||||||
Jonas LindCare assistant | 48 / 40h8h over | |||||||
Chloe MartinCare assistant | 40 / 40hOn contract | |||||||
Sam ReyesCare assistant | 32 / 32hOn contract | |||||||
On shiftof needed |
|
|
|
|
|
|
|
4 problems to fix
- Mon late: 1 of 2 staffed
- Sat late: 0 of 1 staffed
- Tom has 8h rest before Wed
- Jonas is 8h over contract
How it works
1.One column per day, generated
The days array becomes seven columns with the same cell and footer. Each cell reads its person and day from the schedule in table meta, so editing a shift never rebuilds the columns. For room allocation, make the rows rooms and the columns time slots; nothing else changes.
...days.map((d, day) => ({id: d.id,cell: ({ row, table }) => <ShiftCell value={getMeta(table).schedule[row.original.id][day]} … />,footer: ({ table }) => <Coverage have={coverage(getMeta(table).schedule, day)} need={required(d)} />,}))
2.Click to pick, or type the letter
A cell opens a small popover with every shift and Off. From the keyboard, the arrow keys move between cells and typing E, L, N or A assigns that shift and moves to the next day, so a week can be typed in one go. Delete clears a cell. Only the current cell is in the tab order, so Tab leaves the grid instead of stopping 56 times.
const value = fromKey(event.key)if (value === undefined) returnassign(personId, day, value)if (value !== null) focusCell(row, day + 1)
3.Rules are checked as you edit
The footer counts who is on each shift against what that day needs, and goes red when a shift is short. A shift that starts less than 11 hours after the one before gets a red outline, and the Hours column compares the week with the contract. All three are plain functions of the schedule.
export function restBefore(week: Assignment[], day: number) {const prev = week[day - 1]const next = week[day]if (!prev || !next || prev === 'leave' || next === 'leave') return nullreturn 24 + shiftById[next].start - shiftById[prev].end}
4.Draft, then publish
Edits change a draft. Cells that differ from the published schedule get a blue dot, and Publish or Discard settles all of them at once, so people are not notified about every click.
const changed = useMemo(() => changes(published, schedule), [published, schedule])