Command palette

@yasinsensoy/web

Web · Components

EventCalendar

Event calendar and scheduler: month, week, day, agenda and year views.

24 exports

Live example

Preview

All day

Change the recurring event?

New event

Code

import { CalendarEvent, EventCalendar } from "@yasinsensoy/web";

const [events, setEvents] = useState<CalendarEvent[]>([
  { id: 1, title: "Daily standup", start: "2026-11-02T09:30", end: "2026-11-02T09:45",
    recurrence: "FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR", color: "chart-7" },
  { id: 2, title: "Tech fair", start: "2026-11-04", end: "2026-11-06", color: "chart-4" },
]);

<EventCalendar
  events={events}
  className="h-[80dvh]"
  businessHours={{ start: "09:00", end: "18:00" }}
  onEventChange={(d) => setEvents((l) => applyEventChange(l, d))}
  onEventDelete={(s) => setEvents((l) => applyEventDelete(l, s))}
  onEventCreate={(field) => formuAc(field)}
  onEventEdit={(t) => formuAc(t.event)}
/>

Events

  1. Events appear here when you interact with the preview.

Loading from the server range by range (onRangeChange + loading)

Sun
Mon
Tue
Wed
Thu
Fri
Sat

Change the recurring event?

Read-only agenda, custom row rendering

Change the recurring event?

Import

import {
  EventCalendar,
  defaultEventCalendarMessages,
  enEventCalendarMessages,
  describeRecurrence,
  parseRecurrence,
  formatRRule,
  getOccurrences,
  applyEventChange,
  applyEventDelete,
} from "@yasinsensoy/web";

EventCalendar

componentClient component

Event calendar and scheduler: month, week, day, agenda and year views.

  • Editing: Events are moved by dragging and resized from their bottom/top edge (the right edge in month view). A timed event dropped on the all-day row becomes all-day, and vice versa. Dragging over an empty area selects a new event range. Everything snaps to 15 minutes.
  • Recurring events: A subset of RFC 5545 RRULE (daily, weekly, monthly "last Friday of the month", yearly, count, until, excluded days). When an occurrence changes, "This event / This and following / All" is asked; applyEventChange applies the result to the list.
  • Mobile: In narrow areas the week shrinks to 3 days; swipe left/right to navigate; long press an event to drag it; details open in a bottom sheet.
  • Keyboard: On an event Enter opens the details, Alt+arrows move it, Alt+Shift+↑/↓ changes the duration, Delete deletes it. PageUp/PageDown go to the previous/next range.
  • Times are wall-clock times ("2026-10-31T14:30"); no time zone conversion is done. The locale and week start come from the UIProvider locale.
EventCalendar(props: EventCalendarProps<T>): JSX.Element

Examples

const [events, setEvents] = useState<CalendarEvent[]>([
  { id: 1, title: "Planning", start: "2026-11-02T10:00", end: "2026-11-02T11:00",
    recurrence: "FREQ=WEEKLY;BYDAY=MO", color: "chart-3" },
  { id: 2, title: "Trade fair", start: "2026-11-04", end: "2026-11-06" },
]);

<EventCalendar
  events={events}
  defaultView="week"
  className="h-[80dvh]"
  onEventChange={(d) => setEvents((l) => applyEventChange(l, d))}
  onEventDelete={(s) => setEvents((l) => applyEventDelete(l, s))}
  onEventCreate={(slot) => openForm(slot)}
/>

Default (Turkish) texts.

defaultEventCalendarMessages: EventCalendarMessages

English texts.

enEventCalendarMessages: EventCalendarMessages

Turns a recurrence rule into readable text: "Every week: Monday, Wednesday", "Every month, on the last Friday", "Every 2 days, 10 times". Use it in the detail card and your own forms.

describeRecurrence(rule: RecurrenceRule | string, locale?: string, messages?: Partial<EventCalendarMessages>): string

Examples

describeRecurrence("FREQ=WEEKLY;BYDAY=MO,WE", "en-US", enEventCalendarMessages) // "Every week: Monday, Wednesday"
describeRecurrence({ freq: "monthly", byWeekday: [{ day: 5, nth: -1 }] }) // "Her ay, ayın son Cuma"

Turns an RFC 5545 RRULE string into a RecurrenceRule object; undefined when not recognized. An "RRULE:" prefix is allowed. Supported fields: FREQ, INTERVAL, COUNT, UNTIL, BYDAY, BYMONTHDAY, BYMONTH.

parseRecurrence(value: RecurrenceRule | string | null | undefined): RecurrenceRule | undefined

Examples

parseRecurrence("FREQ=MONTHLY;BYDAY=-1FR")
// { freq: "monthly", byWeekday: [{ day: 5, nth: -1 }] }

formatRRule

function

Turns a RecurrenceRule object into an RFC 5545 RRULE string (without the "RRULE:" prefix). To write calendar files (.ics) or store it in one database field.

formatRRule(rule: RecurrenceRule): string

Examples

formatRRule({ freq: "weekly", byWeekday: [1, 3] }) // "FREQ=WEEKLY;BYDAY=MO,WE"

Occurrences of the events (recurrences expanded) between the given days. For your own lists, notifications or exports.

getOccurrences(events: readonly T[], from: DateInput, to: DateInput): EventOccurrence<T>[]

Examples

getOccurrences(events, "2026-11-01", "2026-11-30").length

Applies an EventChange to the event list and returns the new list (does not mutate the input). For recurring events, by scope:

  • "this": the occurrence is excluded from the series (exclude) and a new one-off event is added in its place.
  • "following": the series ends before this occurrence (until/count) and a new series starts from it.
  • "all": the whole series shifts by the same amount (weekly days shift too).
applyEventChange(events: readonly T[], change: EventChange<T>, options?: ApplyChangeOptions<T>): T[]

Examples

<EventCalendar events={events}
  onEventChange={(change) => setEvents((list) => applyEventChange(list, change))} />

Applies an EventDeletion: a non-recurring event is deleted; for a recurring one, by scope the occurrence is excluded ("this"), the series ends before it ("following") or the whole series is deleted ("all").

applyEventDelete(events: readonly T[], deletion: EventDeletion<T>): T[]

Examples

onEventDelete={(deletion) => setEvents((list) => applyEventDelete(list, deletion))}

Values passed to the function that renders the detail card's content.

NameTypeDescription
occurrenceEventOccurrence<T>The clicked occurrence (for recurrences, that day's occurrence).
close() => voidCloses the card.

Props of the EventCalendar component.

NameTypeDefaultDescription
eventsreadonly T[]Events. Recurring ones (recurrence) are expanded for the visible range; even with thousands of events only the visible range is computed.
view?EventCalendarViewView when controlled.
defaultView?EventCalendarView"week"Initial view when uncontrolled.
onViewChange?(view: EventCalendarView) => voidCalled when the view changes.
views?readonly EventCalendarView[]["month", "week", "day", "agenda"]Views offered in the view switcher (in order). If a single view is given, the switcher is hidden.
date?DateInputShown day when controlled ("2026-10-31" or a Date).
defaultDate?DateInputtodayInitial day when uncontrolled.
onDateChange?(date: string) => voidCalled with the ISO day when the shown day changes.
onRangeChange?(range: EventCalendarRange) => voidCalled when the visible range changes (on first render too). For loading events from a server range by range.
onEventClick?(occurrence: EventOccurrence<T>) => voidCalled when an event is clicked. Also called while the detail card (eventDetails) is open.
onEventChange?(change: EventChange<T>) => voidCalled when an event is dragged or resized. If given, events become editable. For a recurring event, "This event / This and following / All" is asked first. Use applyEventChange to update the list.
onEventCreate?(slot: EventSlot) => voidCalled when an empty area is clicked or a range is selected by dragging (long press and drag on touch). If given, areas become selectable; usually a form window opens.
onEventDelete?(deletion: EventDeletion<T>) => voidThe "Delete" button in the detail card and the Delete key on the focused event. Can be applied with applyEventDelete.
onEventEdit?(occurrence: EventOccurrence<T>) => voidThe "Edit" button in the detail card. If omitted, the button is not shown.
eventDetails?boolean | ((event: T, context: EventDetailsContext<T>) => ReactNode)trueDetail card that opens next to the event on click (a bottom sheet on mobile). false disables it; with a function you render the card body.
renderEvent?(event: T, info: EventRenderInfo) => ReactNodeTo render the inside of the event box yourself.
editable?booleantrue` if `onEventChange` is givenAre dragging and resizing enabled? Can be disabled per event with editable: false.
selectable?booleantrue` if `onEventCreate` is givenIs empty area selection enabled?
weekStartsOn?0 | 1 | 2 | 3 | 4 | 5 | 6First day of the week. If omitted, by locale (Monday for tr-TR).
minTime?string"00:00"First hour of the time grid.
maxTime?string"24:00"Last hour of the time grid ("24:00" is end of day).
slotDuration?number30Interval of the thin lines in the grid (minutes).
snapDuration?number15Snap interval while dragging (minutes).
hourHeight?number48Height of one hour (px).
scrollToTime?stringTime to scroll to when the week/day view opens ("08:00"). If omitted, one hour before now if today is visible, otherwise 08:00.
businessHours?BusinessHoursBusiness hours; outside them is shown dimmed.
narrowDays?number3Number of days in the week view on narrow areas (below 640 px); swipe to move between days.
agendaDays?number30Number of days shown on one page of the agenda.
showWeekNumbers?booleanfalseShow ISO week numbers?
dimPastEvents?booleantrueShow past events dimmed?
defaultDuration?number60Duration of a timed event with no duration (minutes).
loading?booleanShows a thin loading bar on top (e.g. while a range loads).
toolbar?booleantrueToolbar (today, previous/next, title, view switcher).
toolbarEnd?ReactNodeItems appended to the end of the toolbar (e.g. a "New event" button).
messages?Partial<EventCalendarMessages>Texts of this calendar; for the whole app use the ui.eventCalendar namespace of the dictionary. See EventCalendarMessages.
locale?stringLocale of date and time formats. If omitted, the UIProvider locale.
className?string"h-[42rem]"Classes of the container. The height is set here.
aria-label?stringScreen reader name.

Calendar views.

type EventCalendarView = "month" | "week" | "day" | "agenda" | "year"

Texts of EventCalendar. Pass only the ones you want to change with messages; the rest are the Turkish defaults. Placeholders such as {count} are replaced with values.

NameTypeDefaultDescription
labelstring"Etkinlik takvimi"Screen reader name of the calendar.
todaystring"Bugün"
previousstring"Önceki"
nextstring"Sonraki"
monthstring"Ay"View names.
weekstring"Hafta"
daystring"Gün"
agendastring"Ajanda"
yearstring"Yıl"
daysstring"{count} gün"Name of the week view on narrow screens.
viewstring"Görünüm"Screen reader name of the view picker.
goToDatestring"Tarihe git"Go to date button.
allDaystring"Tüm gün"
morestring"+{count} daha"Events that do not fit.
showLessstring"Daralt"Collapses the all-day row.
noEventsstring"Bu aralıkta etkinlik yok"When the agenda has no events.
newEventstring"Yeni etkinlik"Name of the new event created while dragging.
untitledstring"(Başlıksız)"Untitled event.
editstring"Düzenle"
deletestring"Sil"
closestring"Kapat"
confirmstring"Tamam"
cancelstring"İptal"
recurringChangestring"Tekrarlayan etkinlik değiştirilsin mi?"Question asked when changing a recurring event.
recurringDeletestring"Tekrarlayan etkinlik silinsin mi?"
scopeThisstring"Bu etkinlik"
scopeFollowingstring"Bu ve sonraki etkinlikler"
scopeAllstring"Tüm etkinlikler"
weekNumberstring"{week}. hafta"Week number.
keyboardHintstring"Taşımak için Alt ve ok tuşları, süreyi değiştirmek için Alt, Shift ve yukarı/aşağı ok"Keyboard hint (screen reader).
touchHintstring"Taşımak için basılı tutup sürükleyin"Touch hint (screen reader, React Native).
moveEarlierstring"Erkene al"Accessibility action: move 15 minutes (the snap interval) earlier.
moveLaterstring"İleriye al"
movePreviousDaystring"Önceki güne taşı"
moveNextDaystring"Sonraki güne taşı"
lengthenstring"Uzat"
shortenstring"Kısalt"
dailystring"Her gün"Recurrence texts.
everyDaysstring"{count} günde bir"
weeklystring"Her hafta"
everyWeeksstring"{count} haftada bir"
monthlystring"Her ay"
everyMonthsstring"{count} ayda bir"
yearlystring"Her yıl"
everyYearsstring"{count} yılda bir"
onMonthDaystring"ayın {day}. günü"
onLastMonthDaystring"ayın son günü"
onNthWeekdaystring"ayın {nth}. {weekday}"
onLastWeekdaystring"ayın son {weekday}"
untilstring"{date} tarihine kadar"
timesstring"{count} kez"

Day of the week: 0 Sunday, 1 Monday … 6 Saturday.

type Weekday = 0 | 1 | 2 | 3 | 4 | 5 | 6

NthWeekday

interface

Which weekday of the month or year: { day: 2, nth: 1 } is the first Tuesday of the month, { day: 5, nth: -1 } the last Friday.

NameTypeDescription
dayWeekdayDay of the week (0 Sunday … 6 Saturday).
nthnumberWhich one: 1 first, 2 second … ; -1 last, -2 second to last.

CalendarEvent

interface

An event in the calendar. Times are wall-clock times (no time zone): "2026-10-31T14:30", "2026-10-31" for all day, or a Date (local time).

Extends: Core.CalendarEvent

NameTypeDescription
className?stringClasses added to the event box.

A change made by dragging, resizing or the keyboard.

type EventChange = Core.EventChange<T>

Delete request.

type EventDeletion = Core.EventDeletion<T>

An occurrence in the visible range (for recurrences, that day's occurrence).

type EventOccurrence = Core.EventOccurrence<T>

A recurrence rule. A commonly used subset of the RFC 5545 (iCalendar) RRULE; the same rule can be given as text too ("FREQ=WEEKLY;BYDAY=MO,WE"). See parseRecurrence.

NameTypeDefaultDescription
freq"daily" | "weekly" | "monthly" | "yearly"Frequency.
interval?number1Every how many units (2 → every two weeks).
count?numberTotal number of occurrences (the first included). Not given together with until.
until?DateInputLatest day of the last occurrence (inclusive).
byWeekday?readonly (Weekday | NthWeekday)[]Days of the week. Which days in weekly; with nth in monthly/yearly, like "the first Monday of the month"; a filter in daily.
byMonthDay?readonly number[]Days of the month (1–31; -1 is the last day of the month).
byMonth?readonly number[]Months (1 January … 12 December).

Examples

{ freq: "daily" }                                   // every day
{ freq: "weekly", byWeekday: [1, 3, 5] }            // Monday, Wednesday, Friday
{ freq: "weekly", interval: 2, count: 6 }           // every two weeks, 6 times
{ freq: "monthly", byWeekday: [{ day: 5, nth: -1 }] } // last Friday of every month
{ freq: "monthly", byMonthDay: [15] }               // the 15th of every month
{ freq: "yearly", until: "2030-12-31" }             // same day every year, until the end of 2030

Which occurrences of a recurring event change.

type RecurringScope = "this" | "following" | "all"

EventSlot

interface

A time range selected by dragging or clicking on empty space.

NameTypeDescription
startstringStart: "YYYY-MM-DDTHH:mm" when timed, "YYYY-MM-DD" when all-day.
endstringEnd: the end instant when timed, the last day (inclusive) when all-day.
allDaybooleanSelected from the all-day row or the month view?

Options: id of the new event in operations that split an occurrence off. "<id>-<YYYY-MM-DD>" when omitted.

NameTypeDescription
createId?(event: T, occurrenceStart: string) => string | numberBuilds an id for a split occurrence or a new series.

Info passed to the EventCalendarProps.renderEvent function.

NameTypeDescription
viewEventCalendarViewWhich view it is rendered in.
variant"timed" | "bar" | "dot" | "agenda"Shape of the box: "timed" is a box in the time grid, "bar" an all-day or multi-day bar, "dot" a timed row in month view, "agenda" an agenda row.
timestringFormatted time range ("09:00 – 10:30"); empty if all day.
draggingbooleanIs it being dragged?