Todae

Todae

Scheduler

A recipe, not a package namespace. A scheduler places items on parallel lanes, such as rooms, people or machines, along one time axis, where an item can't go where one of the things it uses is busy, even on another lane. Items wait in a queue until they are placed. Dragging comes from useLaneDrag, and each item's Menu and a Dialog make the same moves from the keyboard. The time helpers and the conflict rule live in the recipe, so change them to fit your product. There is no Scheduler.* export.

On this page

The example is a three-day conference. Each stage is a lane, and a talk can't go where its stage or one of its speakers is busy. Drag a talk by its grip to another time, stage or day, or an end of it to change its length. Select a talk to open its menu and move it without dragging, or pick a speaker to see their talks on every stage.

import {
  Alert,
  Badge,
  Button,
  Dialog,
  ErrorMessage,
  Field,
  Form,
  Label,
  Menu,
  ScrollArea,
  Text,
  ToggleGroup,
  formatTime,
  useAnnouncer,
  useFocusHandoff,
  useLaneDrag,
  useLaneDragState,
  type CategoryTone,
  type FormErrors,
.schedule {
  --names: 10rem;
  --header: 4.5rem;
  --axis: calc(var(--minutes) * var(--minute));
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  gap: var(--todae-space-4);
  inline-size: 100%;
  min-inline-size: 0;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: var(--todae-space-3);
}

.jump {

Wed, Jun 2

Opening keynote 9:00 AM–10:00 AM · Lunch 12:30 PM–1:30 PM

Main stage

800 seats · Recorded

Hall B

300 seats · Recorded

Workshop room

40 seats · Open 10:00 AM–5:00 PM

Unscheduled

  • Dark mode, done right

    30 min · Mira Patel

    DesignTalk
  • Hands-on accessible forms

    120 min · Sam Okafor

    DesignWorkshop
  • Lightning talks

    45 min · Ana Ruiz, Priya Nair, Leo Brandt

    ResearchPanel
  • Migrating to 1.0

    30 min · Kenji Sato

    EngineeringTalk

The time axis

useLaneDrag places items along plain numbers, so the recipe counts minutes of open hours only: timeline() turns each day's opening and closing in the venue's time zone into a segment, and the nights drop out. Here day 1 is 0 to 540 and day 2 is 540 to 1080, so a drag from one day to the next is a drag along one lane. toUnits() and fromUnits() turn a Temporal.ZonedDateTime into a point and back, and snapGrid() lists the points a talk snaps to, every step from each opening and at each closing.

The end of one day and the start of the next are the same point, so each helper takes an edge: a start at 540 is 9:00 on day 2, and an end at 540 is 18:00 on day 1. A talk whose end lands past its day's closing is blocked as running past closing, since it would cross the night.

Units are elapsed minutes. A day the clock changes is as long as it really is, and a wall time the change skips or repeats becomes the later or the earlier one, as Temporal's compatible does. The board shows times in the venue's zone, as most event schedules do.

Stages and talks

Each stage is a section named by its heading, with its talks in an ol that the same heading names, in start order. The name, its seats, whether it's recorded and any opening hours stay in a sticky first column. Every row is as wide as the names column and the whole axis: a sticky element stays inside its parent, so a row only as wide as the board would carry its stage name away once the board scrolled past the row's end. The header row is sticky too, and its corner covers the hours as they scroll under the names. Each day's header names the day and lists its breaks and keynotes in text, which the board draws as stripes across every stage.

A talk is an li placed with inset-inline-start and inline-size as fractions of the axis, so nothing is measured. Its leading edge takes its track's category color. Past its grip, the talk is its menu button, so its title, start time and speakers take the room a separate button would. Text's lines clamps the title to two lines and the time to one, and shows a cut title whole in a tooltip on hover or keyboard focus. The button is the one part a screen reader reads, and its name says everything the talk shows, in the order it shows it, and more: the title, start time and speakers, then the day and end time, track, stage and any warning. A talk with less than about 6rem past its leading edge and end handle drops its grip, its ends and its warning icon and keeps its text, and its button still makes every move a drag would. The outline still marks a warning, and a picked talk's ring sits above the button, so neither hides while the button is hovered or pressed. Unscheduled talks wait in a queue beside the board on a wide screen and under it on a narrow one, each with its length, speakers, track and format.

The board is a ScrollArea that scrolls both ways and takes a Tab stop, so a keyboard can scroll it. It opens on "One day", which shows a single day, snaps to 5 minutes and leaves a talk of half an hour or more its grip. "Whole event" shows every day and snaps to 15. "Whole event" is for seeing the event at a glance: an hour there is 9.375rem, so a half-hour talk still shows a word or two of its title, set in the smaller label size and hyphenated where English allows, and a talk shorter than 45 minutes has no grip, so drag in "One day". A talk shorter than half an hour has little room for text at "Whole event"; its button's name and the tooltip on focus still say what it is. A zoom keeps the time at the board's start in view, and the day that time is in. In "One day" the day buttons select that day and show which one is selected. In "Whole event" they scroll the board to a day. The board's scroll-padding covers exactly the sticky names column and header row, so a day's stop and a focused talk stay clear of them, and a scroll-margin on each day and talk menu adds a focus ring's room past them.

The rules

findConflicts() is the one conflict rule. Each booking lists the keys it uses, here its stage and each speaker, and two bookings that share a key and overlap conflict, on whatever lanes they sit. A closed window takes keys too, or every key: breaks and keynotes close every stage and speaker, the workshop room's hours close that stage, and a speaker who arrives on day 2 closes their key on day 1. A buffer finds bookings that share a key and sit too close, such as talks on one stage with less than 10 minutes to change over. The axis leaves the nights out, so the end of one day sits next to the start of the next, and the recipe counts a changeover only within a day.

verdictFor() turns what it finds into the verdict useLaneDrag's check returns:

  • Blocked: a closed window, a stage or speaker already busy, past closing, or a recorded talk on a stage that isn't recorded.
  • Warning: more people expected than the stage seats, less than the changeover, or two talks of one track at once.

The drag, the menu and the dialog all ask verdictFor(), so they can't disagree. A talk that sits with a warning shows an outline, a warning icon where it has room, and the warning in its name between drags. A blocked place marks every talk it overlaps on its stage or with one of its speakers, even when a closed window is the reason. One that runs past closing marks none, since the rest of it would fall on the next morning. The example checks every talk against every other, which is quick for a few dozen; for hundreds, index the bookings by key, so a check reads only the dragged talk's stage and speakers.

Moving without dragging

Each talk's menu moves it 15 minutes earlier or later, to another stage at the same time, or back to the queue, and a talk in the queue goes to the first time on a stage with no warning, or else the first a rule allows. A move a rule blocks stays in the menu as unavailable, with disabled. "Change time or stage…" opens a dialog with a Field.Select for the stage and the day, a Field.TimeInput for the start and a Field.NumberInput for the length. A blocked place is a Form error on the start time, which a change to any field clears, and a warning shows in an Alert as the fields change.

A talk that changes stage leaves one list and joins another, so its old element goes away. useFocusHandoff sends focus from it to the moved talk's menu button. The Dialog stays mounted and opens from state, since a dialog removed while open has no close to restore focus on. Its restoreFocusRef holds the menu button of the talk it edits, so focus goes back to that talk wherever it is when the dialog closes. Every move is announced with useAnnouncer, with the stage, day, times and any warning.

Dragging

useLaneDrag takes the visible range, one day's segment in "One day" and the axis's range in "Whole event", the snap points inside that range, the shortest talk as minSpan, verdictFor() as check, and an onDrop that calls the same move function as the menu. Spread getBoardProps() on the element that scrolls, getLaneProps(stage) on each lane, getQueueProps() on the queue's list, getItemProps() on each talk, and getHandleProps() on its grip and its two ends. A talk in the queue drags out at its length, and a placed one dropped on the queue goes back to it.

During a drag the hook marks the lane under the pointer and the talks the place conflicts with, such as a speaker's other talk on another stage, with data-conflict, and the stylesheet outlines them without a render. A preview in each lane reads the drag with useLaneDragState and draws the place, its times and the verdict's reason with an icon. A blocked place takes no drop. useLaneDrag counts its auto-scroll edge from past the board's scroll-padding, so the board scrolls while the pointer is near the names or over them, and a drop over the names lands at the first place in view, such as the start of a day.

The grip and the ends are aria-hidden and not tab stops, since the menu and the dialog are the keyboard's way. Each has touch-action: none, so a finger drags from them while a swipe anywhere else scrolls the board.

Undo and saving

Each move keeps the schedule it replaced, and Undo puts the last one back and says what it undid. The example saves nothing. If your product saves a move and the save fails, put the talk back and say so with a Toast, since the announcement already said it moved. When two organizers edit at once, check the version you saved against before applying a move.

Accessible composition

Todae handles: useLaneDrag drags a talk from its grip or an end with a mouse, a finger or a pen, works out the snapped place from the lane's box and the text direction, asks the rules, refuses a blocked drop, marks the talks in conflict, and cancels on Escape. Menu reads a disabled move as unavailable and returns focus to its button. The Dialog moves focus in and back, and the Form puts the error on the field. useFocusHandoff moves focus from a talk that changed stage, and useAnnouncer writes each message to a live region.

You supply: A name for each stage that names its section and its list. A name for each talk's menu button that starts with what it shows, the title, start time and speakers in that order, then its day, end time, stage and any warning. A menu and a dialog that make every move a drag makes. The rules and their reasons. A cue for each verdict besides color. Grips and ends hidden from screen readers. Breaks and closed hours in text, not only as stripes. A ref on the menu button of the talk that last moved or opened the dialog. Highlighting that marks the picked talks with more than color and leaves the other talks' text and controls at full contrast.

Watch for: Controls that take a narrow item's room, which leave it showing a button and no title. A row only as wide as the board, which lets a sticky stage name scroll away. Rows that start inside the scroll area's room for focus rings, which lets the names and header row slide by that room before they stick. A scroll-padding wider than the sticky parts, which puts a drop over the names a step past a day that starts right at their edge. A dialog unmounted while open, which drops focus on the page. A changeover counted across a night. Times shown in the browser's zone when the event's are meant. A talk crossing a night on a collapsed axis. A conflict that only shows on the talk's own stage. A move that only dragging can make (WCAG 2.2 SC 2.1.1 and SC 2.5.7). A conflict shown by color alone (SC 1.4.1). Many stages of talks, each a tab stop: arrow keys inside a lane with useRovingFocus keep Tab to one stop a stage.

When to use

When: People place items on parallel lanes along time, where an item's resources can clash across lanes, such as talks on stages, shifts on a rota or bookings of rooms.

When not: One ordered list → the Reorder recipe. Items that move between stages of work with no time → the Kanban recipe. Picking one date or time → the Date and time picker recipe.