Time grid
Day, work week or week as columns of hours: overlapping events side by side, an all-day row, the now line, create and move by pointer or keyboard.
import { TimeGrid } from "@forgeron/ui";Nov 16 – Nov 20, 2026W47
Mon 16
Tue 17
Wed 18
Thu 19
Fri 20
All day
// A work week: overlapping events side by side, an all-day row, working hours, the now line.
import { TimeGrid } from "@forgeron/ui";
const events = [
{
id: "1",
title: "Standup",
date: "2026-11-18",
start: "09:00",
end: "09:30",
color: "var(--accent)",
},
{ id: "2", title: "Design review", date: "2026-11-18", start: "09:15", end: "10:30" },
{
id: "3",
title: "Planning",
date: "2026-11-19",
start: "14:00",
end: "15:30",
color: "var(--success)",
},
{ id: "4", title: "Offsite", date: "2026-11-20", start: "00:00", end: "24:00", allDay: true },
];
const hours = [1, 2, 3, 4, 5].map(() => [{ start: "09:00", end: "18:00" }]);
export default function WorkWeek() {
return (
<div style={{ width: "100%", height: 420, display: "flex", border: "1px solid var(--line)" }}>
<TimeGrid
records={events}
date="2026-11-18"
now="2026-11-18T10:07"
scrollTo={8}
workingHours={[...hours, [], []]}
/>
</div>
);
}Wednesday 18 November 2026
Wed 18
// Drag empty space to create, drag an event to move it, its foot to resize it. Arrows move,
// Shift and arrows resize, Enter on a column creates.
import { TimeGrid, type TimeGridChange } from "@forgeron/ui";
import { useState } from "react";
interface Item {
id: string;
title: string;
date: string;
start: string;
end: string;
}
export default function Editable() {
const [items, setItems] = useState<Item[]>([
{ id: "a", title: "Interview", date: "2026-11-18", start: "10:00", end: "11:00" },
{ id: "b", title: "Lunch", date: "2026-11-18", start: "12:30", end: "13:30" },
]);
const update = (id: string, c: TimeGridChange) =>
setItems((list) => list.map((i) => (i.id === id ? { ...i, ...c } : i)));
return (
<div style={{ width: "100%", height: 420, display: "flex", border: "1px solid var(--line)" }}>
<TimeGrid
records={items}
defaultView="day"
date="2026-11-18"
now="2026-11-18T10:07"
scrollTo={8}
onChange={update}
onCreate={(c) =>
setItems((list) => [...list, { id: String(list.length + 1), title: "New event", ...c }])
}
/>
</div>
);
}Wednesday 18 November 2026
Ana
Bob
// The columns of a day are resources: chairs, rooms, people.
import { TimeGrid } from "@forgeron/ui";
const events = [
{ id: "1", title: "Cut", date: "2026-11-18", start: "09:00", end: "10:00", resource: "ana" },
{ id: "2", title: "Colour", date: "2026-11-18", start: "09:30", end: "12:00", resource: "bob" },
{ id: "3", title: "Cut", date: "2026-11-18", start: "14:00", end: "14:45", resource: "ana" },
];
export default function Resources() {
return (
<div style={{ width: "100%", height: 380, display: "flex", border: "1px solid var(--line)" }}>
<TimeGrid
records={events}
date="2026-11-18"
now="2026-11-18T10:07"
scrollTo={8}
hours={[8, 19]}
resources={[
{ id: "ana", name: "Ana", color: "var(--accent)" },
{ id: "bob", name: "Bob", color: "var(--success)" },
]}
/>
</div>
);
}API → Props
| Prop | Type | Default | Description |
|---|---|---|---|
records | T[] | — | Events, meetings, shifts, bookings: anything with a day and times. |
getId / getLabel / getColor | (record) => string | id, title or name, color | How a record is read. |
getDate / getStart / getEnd | (record) => string | null | date, start, end | The day (YYYY-MM-DD) and the times (HH:mm; 24:00 ends the day). |
getAllDay / getEndDate | (record) => boolean | string | allDay, endDate | Records of the all-day row, and the last day of one that spans several. |
getResource | (record) => string | record.resource | The resource column of a record. |
resources | { id, name, color? }[] | — | Columns per resource (rooms, people, chairs); with the day view, the columns of one day. |
renderEvent / renderAllDay | (record, info) => ReactNode | — | The inside of an event (info: date, start, end, compact) and of an all-day chip. |
view / defaultView | "day" | "workweek" | "week" | — | The days shown. Controlled or not. |
views / onViewChange | GridView[] | all three | The views the toolbar offers, and a listener. |
date / defaultDate | string | — | The day in focus: its day or week is shown. Controlled or not. |
onDateChange | (date) => void | — | When the toolbar, Page Up and Page Down or an edge arrow move the day. |
now | string | the device's clock | YYYY-MM-DDTHH:mm: places the ember line and today. Fix it in tests. |
hours | [number, number] | [0, 24] | The hours drawn. |
scrollTo | number | 7 | The hour at the top when the grid appears. |
hourHeight / step / defaultDuration | number | 48 / 15 / 60 | px per hour, the snap in minutes, the length of an event made by double click or Enter. |
workingHours | TimeSpan[][] | (date, resource?) => TimeSpan[] | — | Seven lists (Monday first, like Availability.weekly) or a function; the rest is hatched. |
hour12 | boolean | false | Times with AM and PM. |
selected / defaultSelected | string | null | — | The current event. Controlled or not. |
onSelectedChange / onOpen | (id) => void | — | A click moves the current event; Enter or a click opens it. |
onCreate | (slot: TimeGridChange) => void | — | Makes empty space create: drag, double click, or on a focused column the arrows (cursor), Shift (length) and Enter. |
onChange | (id, change: TimeGridChange) => void | — | Makes events movable and resizable: drag, drag the foot, arrows, Shift and arrows. Left and right change day or resource column. |
toolbar / allDayRow / label | boolean / boolean / string | true / only when needed | Today, previous, next and views; the all-day row; the name of the grid. |
className | string | — | Extra classes. |