Import

import-scheduler.tsx
import { NuiScheduler, type NuiSchedulerHandle } from '@needless-ui/react/scheduler';

NuiScheduler

Events in a month, a week, a day, an agenda or a timeline.

NuiScheduler: Properties
NameTypeDefaultDescription
eventsPropNuiSchedulerEvent<T>[][]The events to show.
resourcesPropNuiSchedulerResource[][]Rooms, people or machines: rows of the timeline, and columns of the day and the week.
view
defaultView
onViewChangeState
'month' | 'week' | 'day' | 'agenda' | 'timeline''week'The view shown.
viewsPropNuiSchedulerView[]allThe views people can switch between. By default all of them, the timeline only with resources.
timelineSpanProp'day' | 'week' | 'month''day'What the timeline shows: a day by its slots, or a week or a month by its days.
date
defaultDate
onDateChangeState
NuiDatetodayThe day shown, and where the keyboard is. Pass defaultDate when a server renders the scheduler: its today may not be the reader’s.
slotMinutesPropnumber30Minutes per row of the time grid, or per column of a day’s timeline.
snapMinutesPropnumberslotMinutesThe step events move and resize by.
dayStart, dayEndPropnumber0, 24The hours the time grid shows, from and to.
scrollHourPropnumber8The hour the time grid opens at.
agendaDaysPropnumber30Days the agenda looks ahead.
businessHoursPropNuiSchedulerHours[]Working hours, such as { days: [1, 2, 3, 4, 5], start: '09:00', end: '17:00' }. Other time is shaded.
weekendsPropbooleantrueShows the weekend. Without it, every view leaves out the locale’s weekend.
weekNumbersPropbooleanfalseShows ISO week numbers in the month, and above the times.
editablePropbooleanfalseEvents can be moved and resized, by pointer and keyboard.
selectablePropbooleanfalseTime can be chosen on the grid, to create events.
allowProp(time) => booleanDecides whether a move, a resize or a choice of time can happen.
toolbarPropboolean | ((toolbar: NuiSchedulerToolbar) => ReactNode)trueShows the toolbar, or draws one of your own from what it’s given.
firstDayProp1 … 7The first day of the week, 1 for Monday. By default, the locale’s.
headingLevelPropnumber2The title’s heading level; the agenda’s days are one deeper.
localePropstring'en-US'Formats days and times.
labelsPropPartial<NuiSchedulerLabels>Every text the scheduler shows or announces, to translate.
cornersPropNuiCornersThe shape of its corners: round, squircle, bevel, scoop, notch or square.
radiusPropNuiRadiusHow big its corners are: none, small, medium, large or full.
densityPropNuiDensityHow much room it takes: compact, regular or roomy.
renderEventRender prop(event, { time }) => ReactNodeDraws events yourself, from the event and its time as text.
renderResourceRender prop(resource) => ReactNodeDraws the heads of resources yourself.
onEventClickCallback(event: NuiSchedulerEvent<T>) => voidCalled with an event clicked, or opened with Enter.
onEventChangeCallback({ event, start, end, resource? }) => voidCalled with an event’s new times after a move or a resize, and its resources when they changed. Update events to keep the change.
onSlotSelectCallback({ start, end, allDay, resource? }) => voidCalled with the time chosen on the grid, and its resource.
onRangeChangeCallback({ start, end }) => voidCalled with the first and last day shown when they change, to load their events.
refPropRef<NuiSchedulerHandle>What the scheduler’s ref reaches: paging, for a toolbar of your own.
previous, next, goTodayMethod() => voidShow the previous or next page, or today, for a toolbar of your own.
titlePropertystringWhat’s shown, as the toolbar’s title says it.

State works like React’s own inputs: pass a value and update it from its on…Change callback, or pass a default… value and let the component keep it.

Customization props you leave unset follow the nearest data-nui-* attribute. See the customization guide.

NuiSchedulerToolbar

What a toolbar function gets, to draw a toolbar of your own.

NuiSchedulerToolbar: Properties
NameTypeDefaultDescription
titlePropertystringWhat’s shown, as the toolbar’s title says it.
view, viewsPropertyNuiSchedulerView, NuiSchedulerView[]The view shown, and the views offered.
setView, previous, next, goTodayMethod(view?) => voidSwitch the view, show the previous or next page, or show today.

NuiSchedulerEvent

An event. A timed event’s end isn’t included; an all-day event’s end is its last day.

NuiSchedulerEvent: Properties
NameTypeDefaultDescription
id, titlePropertystringIts key, and what it shows.
start, endPropertyNuiDateTime | NuiDateDates and times, or dates for all-day events.
allDayPropertybooleanBy default, whether start has no time.
toneProperty'accent' | 'neutral' | 'success' | 'warning' | 'danger''accent'Its palette.
color, classPropertystringAny CSS color, which wins over its tone, and classes to style it with.
resourcePropertystring | string[]The resources it belongs to.
rrulePropertystringA repeat rule from RFC 5545, such as FREQ=WEEKLY;BYDAY=MO.
exdatePropertystring[]Starts of occurrences that don’t happen.
recurrenceIdPropertyNuiDateTime | NuiDateOn an occurrence the scheduler reports: the start its rule gave it.
editablePropertybooleanWhether it can be moved, whatever the scheduler says.
dataPropertyTAnything else to keep with it.

NuiSchedulerResource

A room, a person or a machine that events belong to.

NuiSchedulerResource: Properties
NameTypeDefaultDescription
id, titlePropertystringIts key, and the name it shows.
tone, colorPropertyNuiSchedulerTone, stringThe colors of its events, unless they have their own.
businessHoursPropertyNuiSchedulerHours[]When it’s available, instead of the scheduler’s working hours.
dataPropertyRAnything else to keep with it.

Helpers

Functions for repeating events and iCalendar files.

Helpers: Properties
NameTypeDefaultDescription
nuiSchedulerOccurrencesMethod(event, first, last) => NuiSchedulerEvent[]An event as it shows on the days given: each occurrence of a repeating one.
nuiSchedulerRuleMethod(text: string) => NuiSchedulerRule | nullReads a repeat rule, or returns null.
nuiSchedulerToIcsMethod(events, options?) => stringWrites events as an iCalendar file.
nuiSchedulerFromIcsMethod(text, { timeZone? }) => NuiSchedulerEvent[]Reads the events of an iCalendar file, with their times in one time zone.