A line of text inside each bar: cut off where the bar is too narrow, left out where it would say nothing, and held at the view's edge while the bar runs on.
import { useSchedule } from "@umriss-ui/schedule";
The text lies on the main time, not on the lead-in. Its colour follows the bar: light text on a dark bar, dark text on a pale one, measured by contrast in either theme.
label returns the text for each bar: here the work item's name, cut where the bar is narrow and left out of the short reviews.
import { useSchedule } from "@umriss-ui/schedule";
import type { Subtask, Task } from "@umriss-ui/schedule";
/* Pan into the afternoon: a bar that begins before the view keeps its text at
the edge, the way the day band keeps its date. */
const at = (hours: number, minutes = 0) => new Date(2026, 2, 17, hours, minutes).getTime();
const min = (n: number) => n * 60_000;
const DAY: readonly [number, number] = [at(5, 30), at(18)];
const PEOPLE = [
{ id: "arjun", label: "Arjun Mehta" },
{ id: "chloe", label: "Chloe Durand" },
{ id: "eva", label: "Eva Novak" },
];
const PROJECTS: readonly Task[] = [
{ id: "portal", name: "Member portal", color: "light-dark(#2563eb, #6b9bff)" },
{ id: "shop", name: "Online shop relaunch", color: "light-dark(#7c3aed, #a98bfa)" },
{ id: "booking", name: "Booking app", color: "light-dark(#4d7c0f, #8fc43e)" },
];
const WORK: readonly Subtask[] = [
{ id: "w-102", task: "portal", lane: "arjun", from: at(8), to: at(10, 30), leadIn: min(30), leadOut: min(15), name: "Profile page" },
{ id: "w-104", task: "shop", lane: "chloe", from: at(9, 30), to: at(10, 45), leadIn: min(25), name: "Basket keeps items across devices" },
{ id: "w-108", task: "portal", lane: "eva", from: at(11, 30), to: at(12, 15), name: "Test plan review" },
{ id: "w-116", task: "booking", lane: "eva", from: at(15), to: at(15, 30), name: "Device check" },
];
export default function BarLabels() {
const { Schedule, Lane, Subtasks } = useSchedule({ initialView: { domain: DAY } });
return (
<Schedule
ariaLabel="Tuesday, 17 March, with the work items written in"
height={196}
label={(subtask) => subtask.name ?? subtask.id}
>
{PEOPLE.map((person) => (
<Lane key={person.id} id={person.id} label={person.label} />
))}
<Subtasks data={WORK} tasks={PROJECTS} />
</Schedule>
);
}
The keys of First schedule apply here.
From ScheduleProps — the full table stands on First schedule.
| Name | Type | Default | Description |
|---|---|---|---|
height | number | 400 | Height in CSS pixels, both bands included. The width is the host's. |
label | (subtask: Subtask) => string | — | What stands written in a bar: a function from a subtask to a line of text, or nothing for bars without text. The text is cut off with an ellipsis where the bar is too narrow for it and left out where even that would say nothing; a bar that began before the view keeps its text at the view's edge. |
children | ReactNode | — | Lane, Dependencies and Subtasks, in the order they are to stand and
be drawn. |
| Name | Type | Default | Description |
|---|---|---|---|
ariaLabelrequired | string | — | What the schedule shows, for a screen reader: "Plan of week 38". |
From LaneProps — the full table stands on Lanes.
From SubtasksProps — the full table stands on Subtasks.
From Subtask — the full table stands on Subtasks.
| Name | Type | Default | Description |
|---|---|---|---|
idrequired | string | — | The caller's identity of the subtask. |
taskrequired | string | — | The id of the task it belongs to. |
lanerequired | string | — | The id of the lane it sits on. |
fromrequired | number | — | Start of the main time. |
torequired | number | — | End of the main time. |
leadIn | number | — | Duration of the lead-in before the main time; none is zero. |
leadOut | number | — | Duration of the lead-out after the main time; none is zero. |
name | string | — | What the subtask is called, where the schedule names it. |
From Task — the full table stands on Subtasks.
From ScheduleOptions — the full table stands on View.
| Name | Type | Default | Description |
|---|---|---|---|
initialView | ScheduleView | — | The view to start from, read once when the hook first runs; a different
value on a later render is ignored, as React ignores a changed
defaultValue. To go to a view later, call setView. The schedule
remembers none: where a view is kept is the application's decision. |