Scheduler
Events in a month, a week, a day or an agenda, put together from parts: the scheduler holds the events, the view and the date; its views place the events — overlapping ones side by side, bars across their days — and you write how an event looks, once, and the toolbar. Pick a time to create, drag to move, with the keyboard too.
Usage
import { Component, ViewEncapsulation, signal } from '@angular/core';import { ScScheduler, ScSchedulerAgenda, ScSchedulerEvent, type ScSchedulerEventData, ScSchedulerEventTemplate, ScSchedulerEventTime, ScSchedulerMonth, ScSchedulerMore, ScSchedulerMoreTemplate, ScSchedulerNext, ScSchedulerPrevious, ScSchedulerTimeGrid, ScSchedulerTitle, ScSchedulerToday, type ScSchedulerView, ScSchedulerViewButton,} from '@semantic-components/ui';import { SiChevronLeftIcon, SiChevronRightIcon,} from '@semantic-icons/lucide-icons';
interface Meeting extends ScSchedulerEventData { readonly title: string;}
/** Month, week, day and agenda views, with a toolbar; click an event to select it. */@Component({ selector: 'app-basic-scheduler-demo', imports: [ ScScheduler, ScSchedulerToday, ScSchedulerPrevious, ScSchedulerNext, ScSchedulerTitle, ScSchedulerViewButton, ScSchedulerMonth, ScSchedulerTimeGrid, ScSchedulerAgenda, ScSchedulerEventTemplate, ScSchedulerEvent, ScSchedulerEventTime, ScSchedulerMoreTemplate, ScSchedulerMore, SiChevronLeftIcon, SiChevronRightIcon, ], template: ` <div scScheduler #scheduler="scScheduler" [events]="events" [(view)]="view" [(date)]="date" class="h-[40rem]" > <div class="flex flex-wrap items-center gap-2"> <button scSchedulerToday>Today</button> <button scSchedulerPrevious> <svg siChevronLeftIcon></svg> <span class="sr-only">Previous</span> </button> <button scSchedulerNext> <svg siChevronRightIcon></svg> <span class="sr-only">Next</span> </button> <div scSchedulerTitle class="ms-2">{{ scheduler.label() }}</div> <div role="group" aria-label="View" class="ms-auto flex gap-1"> <button scSchedulerViewButton="month">Month</button> <button scSchedulerViewButton="week">Week</button> <button scSchedulerViewButton="day">Day</button> <button scSchedulerViewButton="agenda">Agenda</button> </div> </div>
@switch (scheduler.view()) { @case ('month') { <div scSchedulerMonth class="flex-1"></div> } @case ('agenda') { <div scSchedulerAgenda class="flex-1">No events this month.</div> } @default { <div scSchedulerTimeGrid class="flex-1"></div> } }
<ng-template [scSchedulerEventTemplate]="events" let-event> <button scSchedulerEvent (click)="selected.set(event)"> <span class="font-medium">{{ event.title }}</span> <time scSchedulerEventTime></time> </button> </ng-template> <ng-template scSchedulerMoreTemplate let-count let-day="day"> <button [scSchedulerMore]="day">{{ count }} more</button> </ng-template> </div> <p class="text-muted-foreground text-sm" aria-live="polite"> @if (selected(); as event) { Selected: {{ event.title }} } </p> `, host: { class: 'flex w-full flex-col gap-4' }, encapsulation: ViewEncapsulation.None,})export class BasicSchedulerDemo { private readonly events = eventsAroundToday(); private readonly view = signal<ScSchedulerView>('week'); private readonly date = signal(Temporal.Now.plainDateISO()); private readonly selected = signal<Meeting | null>(null);}
/** Around today, in your time zone. */function eventsAroundToday(): Meeting[] { const timeZone = Temporal.Now.timeZoneId(); const today = Temporal.Now.plainDateISO(); const at = ( days: number, time: string, duration: Temporal.DurationLike, ): Pick<Meeting, 'start' | 'end'> => { const start = today.add({ days }).toZonedDateTime({ timeZone, plainTime: Temporal.PlainTime.from(time), }); return { start, end: start.add(duration) }; }; return [ { id: 'standup', title: 'Stand-up', ...at(0, '09:00', { minutes: 15 }) }, { id: 'review', title: 'Design review', ...at(0, '10:00', { minutes: 90 }), }, { id: 'one-on-one', title: '1:1 with Sam', ...at(0, '10:30', { minutes: 30 }), }, { id: 'lunch', title: 'Team lunch', ...at(-1, '12:30', { hours: 1 }) }, { id: 'planning', title: 'Sprint planning', ...at(1, '14:00', { hours: 2 }), }, { id: 'interview', title: 'Interview', ...at(1, '14:30', { hours: 1 }) }, { id: 'demo', title: 'Product demo', ...at(1, '15:00', { minutes: 45 }) }, { id: 'retro', title: 'Retrospective', ...at(1, '17:00', { hours: 1 }) }, { id: 'focus', title: 'Focus time', ...at(2, '08:00', { hours: 3 }) }, { id: 'conference', title: 'Conference', allDay: true, ...at(3, '00:00', { days: 2 }), }, { id: 'release', title: 'Release', ...at(-2, '16:00', { minutes: 30 }) }, ];}Anatomy
The scheduler holds the state; you write the toolbar, a view, and two templates — how an event looks (in every view) and a crowded day's "more". Events are data: an id, a start and an end (Temporal), all day or not, and your own fields.
import { ScScheduler, ScSchedulerToday, ScSchedulerPrevious, ScSchedulerNext, ScSchedulerTitle, ScSchedulerViewButton, ScSchedulerMonth, ScSchedulerTimeGrid, ScSchedulerAgenda, ScSchedulerEventTemplate, ScSchedulerEvent, ScSchedulerEventTime, ScSchedulerMoreTemplate, ScSchedulerMore,} from '@semantic-components/ui';<div scScheduler #scheduler="scScheduler" [events]="events" [(view)]="view" [(date)]="date" pickable editable (slotPick)="add($event)" (eventChange)="save($event)"> <button scSchedulerToday>…</button> <button scSchedulerPrevious>…</button> <button scSchedulerNext>…</button> <h2 scSchedulerTitle>{{ scheduler.label() }}</h2> <button scSchedulerViewButton="month">…</button>
<div scSchedulerMonth></div> <!-- or scSchedulerTimeGrid, scSchedulerAgenda -->
<ng-template [scSchedulerEventTemplate]="events" let-event> <button scSchedulerEvent (click)="open(event)"> {{ event.title }} <time scSchedulerEventTime></time> </button> </ng-template> <ng-template scSchedulerMoreTemplate let-count let-day="day"> <button [scSchedulerMore]="day">…</button> </ng-template></div>Dates and times
- Events start and end as
Temporal.ZonedDateTime, placed intimeZone(the user's by default); the date shown is aTemporal.PlainDate. - Dates, times and the title are written by
Intlin the app's language (LOCALE_ID); the week starts on the locale's first day. - An event all day, or over more than one day, is a bar across its days — the month, the all-day row — going on into the next week with square ends.
Creating and moving
pickable: an empty time or day — a click, a drag over several, or the keys in the hours — emits(slotPick)with its start, its end and whether it is all day: create the event there.editable: an event dragged (to another time or day), dragged by its bottom edge, or moved by the keys emits(eventChange)with its new times. The scheduler showsevents: save the change and it moves; don't, and it goes back.- Times snap to
slotMinutes(30). A touch scrolls; a tap is a click. - An event's colour is
--sc-scheduler-event(the primary by default), mixed into the background.
Keyboard
- The month is a grid, one Tab stop on its days: ←→ (mirrored right to left), ↑↓ a week, HomeEnd the week's ends, Page UpPage Down a month (with Shift, a year); Enter opens the day. Your events are Tab stops, in order.
- The hours (
pickable): ↑↓ move a slot, ←→ a day, Shift + ↓ makes it longer, Enter picks it — each step read out. - An event (
editable): Alt + ↑Alt + ↓ a slot (a week in the month), Alt + ←Alt + → a day, Alt + Shift + ↓ ends it later; its new times are read out, and the keyboard stays on it. - The title is a polite live region: moving and switching the view are announced.
Examples
Month
import { Component, ViewEncapsulation, signal } from '@angular/core';import { ScScheduler, ScSchedulerEvent, type ScSchedulerEventData, ScSchedulerEventTemplate, ScSchedulerEventTime, ScSchedulerMonth, ScSchedulerMore, ScSchedulerMoreTemplate,Working hours
import { Component, ViewEncapsulation, signal } from '@angular/core';import { ScScheduler, ScSchedulerEvent, type ScSchedulerEventData, ScSchedulerEventTemplate, ScSchedulerEventTime, ScSchedulerNext, ScSchedulerPrevious, ScSchedulerTimeGrid,Over days
import { Component, ViewEncapsulation, signal } from '@angular/core';import { ScScheduler, ScSchedulerEvent, type ScSchedulerEventData, ScSchedulerEventTemplate, ScSchedulerEventTime, ScSchedulerMonth, ScSchedulerMore, ScSchedulerMoreTemplate,Agenda
import { Component, ViewEncapsulation, signal } from '@angular/core';import { ScScheduler, ScSchedulerAgenda, ScSchedulerEvent, type ScSchedulerEventData, ScSchedulerEventTemplate, ScSchedulerEventTime, ScSchedulerNext, ScSchedulerPrevious,Editable
Move: drag, or Alt + ↑Alt + ↓Alt + ←Alt + →; resize: its bottom edge, or Alt + Shift + ↓.
import { Component, ViewEncapsulation, signal } from '@angular/core';import { ScKbd, ScScheduler, ScSchedulerEvent, type ScSchedulerEventChange, type ScSchedulerEventData, ScSchedulerEventTemplate, ScSchedulerEventTime, ScSchedulerMonth,RTL
import { Dir } from '@angular/cdk/bidi';import { Component, LOCALE_ID, ViewEncapsulation, signal } from '@angular/core';import { ScScheduler, ScSchedulerEvent, type ScSchedulerEventData, ScSchedulerEventTemplate, ScSchedulerEventTime, ScSchedulerMonth, ScSchedulerMore,API reference
Each part takes class, merged over the style (cn: a later class wins). The look: the style's frame, and its scheduler key (the day number's and the events' corners).
| Part | Selector | Description |
|---|---|---|
ScScheduler | div[scScheduler] | events, [(view)] ('month', 'week', 'day', 'agenda'), [(date)], timeZone, firstDayOfWeek, pickable, editable, slotMinutes (30); (slotPick), (eventChange). exportAs scScheduler: label(), now(), today(), days(), previous(), next(), goToToday(), goTo(date, view?). |
ScSchedulerToday, ScSchedulerPrevious, ScSchedulerNext | button[…] | The style’s button: today, the month, week or day before or after. Write their text or icons and names. |
ScSchedulerTitle | h1, h2, h3, div[scSchedulerTitle] | What is shown — write {{ scheduler.label() }}; a polite live region. |
ScSchedulerViewButton | button[scSchedulerViewButton] | Switches to its view ("month"…), aria-pressed while shown. Put them in a group you name. |
ScSchedulerMonth | div[scSchedulerMonth] | The month: a grid of weeks, one Tab stop on its days; lines and bars; maxEvents (3). |
ScSchedulerTimeGrid | div[scSchedulerTimeGrid] | Week and day: a column per day, the all-day row, events by time (overlaps side by side), now. startHour (0), endHour (24), scrollToHour (8); --sc-scheduler-hour-height (3rem). |
ScSchedulerAgenda | div[scSchedulerAgenda] | The month’s days with events, each a list. Its content: what it says when nothing is on. |
ScSchedulerEventTemplate, ScSchedulerEvent | ng-template[scSchedulerEventTemplate], button[scSchedulerEvent], a[scSchedulerEvent] | How an event looks, in every view (let-event is your type). The event: a line, a bar, a block, a row; --sc-scheduler-event its colour; Alt with the arrows moves it (editable). |
ScSchedulerEventTime | time[scSchedulerEventTime] | Its times in the app’s language ("10:00 – 11:30 AM"; over days, with the dates; a month’s line, its start). |
ScSchedulerMoreTemplate, ScSchedulerMore | ng-template[scSchedulerMoreTemplate], button[scSchedulerMore] | A crowded day: let-count, let-day="day"; the button opens the day. Write its text. |