Blocks / Time grid

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";
/01 → Work week
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>
  );
}
/02 → Editable
Wednesday 18 November 2026
Arrows move the cursor, Shift and arrows set its length, Enter creates. On an event, arrows move it and Shift with the arrows resizes it.
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>
  );
}
/03 → Resources
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
PropTypeDefaultDescription
recordsT[]—Events, meetings, shifts, bookings: anything with a day and times.
getId / getLabel / getColor(record) => stringid, title or name, colorHow a record is read.
getDate / getStart / getEnd(record) => string | nulldate, start, endThe day (YYYY-MM-DD) and the times (HH:mm; 24:00 ends the day).
getAllDay / getEndDate(record) => boolean | stringallDay, endDateRecords of the all-day row, and the last day of one that spans several.
getResource(record) => stringrecord.resourceThe 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 / onViewChangeGridView[]all threeThe views the toolbar offers, and a listener.
date / defaultDatestring—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.
nowstringthe device's clockYYYY-MM-DDTHH:mm: places the ember line and today. Fix it in tests.
hours[number, number][0, 24]The hours drawn.
scrollTonumber7The hour at the top when the grid appears.
hourHeight / step / defaultDurationnumber48 / 15 / 60px per hour, the snap in minutes, the length of an event made by double click or Enter.
workingHoursTimeSpan[][] | (date, resource?) => TimeSpan[]—Seven lists (Monday first, like Availability.weekly) or a function; the rest is hatched.
hour12booleanfalseTimes with AM and PM.
selected / defaultSelectedstring | 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 / labelboolean / boolean / stringtrue / only when neededToday, previous, next and views; the all-day row; the name of the grid.
classNamestring—Extra classes.