# ScheduleGrid: a rota you edit by drag or from the keyboard

ScheduleGrid is the kit's planner's table: people, rooms or machines as rows, days as columns, and the things in the cells moved between them by drag or from the keyboard. A template drops in from a strip, Alt makes a copy, and a cell that cannot take a shift says why before you let go.

Checked 2 December 2026. By Bohuslav Poláček. https://meadowstack.com/components/schedule-grid/

*Juniper Kitchen's Islington rota for the week of 30 November 2026 on Wednesday 2 December: the gaps per day, a head chef over 48 hours, a week off, days at another branch, two short rests and the labour cost rows.*

A live screen, rendered from the kit's components on the page: https://meadowstack.com/components/schedule-grid/

## What it is for, and what the preview shows

A week that someone plans: a rota, a machine plan, visits by day. The preview is [Juniper Kitchen](https://meadowstack.com/examples/restaurant-staff-rota/)'s rota for its Islington branch as the demo shows it on Wednesday 2 December 2026, rebuilt from the kit with the demo's people, shifts and money. Each day's header says how many places are still empty or that the day is covered; the days already past say nothing more. David Cooper is at 56 hours, over the 48-hour week the demo checks, and works at the Camden branch on Monday and Friday. Oliver Porter is off all week, his cells hatched as leave. Two Wednesday mornings follow late Tuesdays with 9 and 8 hours of rest, under the demo's 11, so they carry the warning glyph.

Under the people sit the footer rows: the day's labour, the expected takings and the share between them, against the demo's target of 25 to 35%. The shift templates wait in the strip under the grid, ready to drop into a cell. The grid keeps the kit's 56rem minimum and scrolls sideways inside its own frame when it is narrower; the demo gives a phone a list by day instead. The screen around it is the [staff rota](https://meadowstack.com/screens/staff-rota/).

## The rules, and where they live

- **The manifest**: use it for a rota, a machine plan or visits by day, as an editor and from the keyboard too; not for hours within a day (`TimeGrid`, `ResourceTimeline`). It replaces "a hand-built rota table with drag and drop".
- **AGENTS.md, Apps do work**: planning views are editors: drag, quick add in an empty cell, copy, live feedback, the same from the keyboard.
- **docs/principles.md, Apps do work**: see at once what a change does, what is missing and how many hours, and do all of it from the keyboard.
- **docs/patterns.md, Time and planning**: a planner's week of people and days, a refusal said before the drop, every step said aloud; and the rota per branch with its gaps, hours, hatched leave and quick add.
- **scripts/check-markup.mjs**: `bare-table` fails a hand-made `<table>` in an app, and `own-scroll` fails `overflow-auto`.
- **docs/audit.md, runtime rules**: `horizontal-overflow` fails a screen whose page scrolls sideways at 390px, which a seven-day table does unless it scrolls inside its own frame or turns into a list.

## What AI coding tools write instead

An HTML table with drag and drop wired into its cells, as the manifest's `replaces` names it. What goes wrong:

- The drop happens first and the rule is checked after, so a shift lands on a day off and is then thrown back with an error. The kit's `refuseDrop` answers while the shift is carried: the cell shows a danger ring with the reason in words, and a drop there nudges the shift back home.
- There is no way to plan without a mouse. The kit's items and templates are buttons: Space picks one up, the arrows choose a cell, Space drops it, Alt with Space drops a copy, Escape cancels.
- The totals wait for a save, so nobody sees the hours or the cost change with the move. The grid's end column and footer are drawn from the app's data, so an optimistic `onDrop` moves them at once.
- The table is the app's own `<table>`, which the markup check flags, and on a phone it pushes the page sideways.

A board does not fit either: a board keeps an order inside a column, while a cell here is a place, a row and a day, so the arrows move in two directions.

## How to use it

- `columns` and `rows`: `id`, `label` (used in announcements) and an optional `header`; rows take a `group` and an `end` cell, such as the week's hours; `groups`, `corner` and `endHeader` name the rest.
- `items` with `getId`, `getLabel`, `getCell` (`{ row, column }`) and `renderItem`; `itemClassName` for a pending look.
- `cellBefore` and `cellAfter` add what is not an item: leave, a shift at another branch, a quick add button.
- `onDrop` receives an item or a template and the cell; `refuseDrop` returns a reason or nothing; `onRefuse` tells the person; `allowCopy` turns on Alt for copies.
- `sources`, `sourcesLabel`: the strip of templates. `isMovable` keeps a paid shift in place; `onResize` adds a grip that lengthens an item by whole days.
- `footer`: rows under the people with a figure per day and one at the end, `total` for the row that sums up.

## Its entry in the manifest

*The component's rules as the kit's manifest states them, the same entry an AI coding tool reads.*

| Manifest field | ScheduleGrid |
| --- | --- |
| What it is | A planner's table: people or machines by day, with things dragged between cells, templates and copies. |
| Use it for | A rota, a machine plan or visits by day: an editor, from the keyboard too. |
| Not for | For hours within a day (TimeGrid, ResourceTimeline) |
| It replaces | A hand-built rota table with drag and drop |
| Screen types | Workspace |
| Import | `import { ScheduleGrid } from "@meadowstack-studio/kit";` |

Read from the kit's component manifest when the site was built (126 components, packages/kit/src/components.json); the same entry answers an AI coding tool through the kit's MCP server.

## Where it runs in the example apps

*The example apps whose code renders a ScheduleGrid, and the modules it sits in.*

| Example app | Modules that render it |
| --- | --- |
| [An app for a packaging and print company](https://meadowstack.com/examples/packaging-print-production/) | Cutting dies |
| [An app for a studio or agency](https://meadowstack.com/examples/agency-capacity-planning/) | Capacity |
| [An app for a construction company](https://meadowstack.com/examples/construction-site-management/) | Crews |
| [An app for restaurants and venues](https://meadowstack.com/examples/restaurant-staff-rota/) | Shifts |

Read from the demo's source when the site was built: 4 of 9 example apps render <ScheduleGrid>, in the modules named here as each app's sidebar names them.

## How the demo calls it

*The rota's grid: a column per day with its gaps in the header, a row per person with the face and the week's hours, the shifts placed by person and date.*

From `apps/demo/src/modules/shifts/components/rota-grid.tsx` in the Meadowstack repository:

```tsx
<ScheduleGrid<Shift>
  label={caption}
  corner={tx("Člověk", "Person")}
  endHeader={
    <>
      {tx("Hodiny", "Hours")}
      <span className="sr-only"> {tx("za týden", "per week")}</span>
    </>
  }
  columns={days.map((day) => ({
    id: day,
    label: formatShortDay(day),
    header: <DayHeader day={day} today={today} gaps={gaps.filter((gap) => gap.date === day)} />,
  }))}
  groups={(["kitchen", "floor"] as const).map((group) => ({ id: group, label: groupLabels[group] }))}
  rows={rows.map((row) => ({
    id: row.person.id,
    label: row.person.name,
    group: row.group,
    // The face beside the name (framework v2, part 5: "tváře v rozpisu směn"); the name stays the label.
    header: (
      <span className="flex min-w-0 items-center gap-2">
        <Avatar name={row.person.name} size="lg" decorative />
        <span className="min-w-0">
          <span className="block truncate text-sm font-medium text-fg">{row.person.name}</span>
          <span className="block truncate text-xs text-fg-muted">{row.hint}</span>
        </span>
      </span>
    ),
    end: <Hours hours={weekHours(weekShifts, row.person.id)} weeklyRest={rest?.weekly.get(row.person.id)} />,
  }))}
  items={items}
  getId={(shift) => shift.id}
  getLabel={(shift) =>
    shiftName(shift, nameOf(shift.personId), facts.pendingTo(shift.id), rest?.daily.get(shift.id))
  }
  getCell={(shift) => ({ row: shift.personId, column: shift.date })}
```

## Questions

### Can a shift be moved with the keyboard?

Yes. Tab to the shift, press Space to pick it up, choose a cell with the arrow keys and press Space to drop it, or Alt with Space for a copy. Escape cancels, and every step is announced with the person and the day.

### How does a cell refuse a shift?

The app's refuseDrop returns a reason, such as a day of approved leave. While the shift is carried over that cell, the cell shows a danger ring and the reason in words; let go there and the shift goes back home, and onRefuse can show a toast.

### Can it copy last week?

The grid copies single shifts with Alt. A whole week is the app's own action: the demo's rota has a Copy last week button that writes the shifts through the module, and the grid shows them as they arrive.

### Does it work on a phone?

The grid keeps a 56rem minimum and scrolls sideways inside its own frame, never the page. The demo shows a phone a list by day instead.

## Related

- [A restaurant rota planned against the takings](https://meadowstack.com/screens/staff-rota/) (Screens)
- [A dispatch plan that checks driving hours on every drag](https://meadowstack.com/screens/dispatch-plan/) (Screens)
- [A roast plan worked out from the orders](https://meadowstack.com/screens/roast-plan/) (Screens)
- [Court bookings on a timeline you drag](https://meadowstack.com/screens/court-bookings/) (Screens)
- [GanttChart: a project schedule with its links and key dates](https://meadowstack.com/components/gantt-chart/) (Components)
- [MonthCalendar: a month of things you move between days](https://meadowstack.com/components/month-calendar/) (Components)
