Import
import { NuiScheduler, type NuiSchedulerHandle } from '@needless-ui/react/scheduler';NuiScheduler
Events in a month, a week, a day, an agenda or a timeline.
| Name | Type | Default | Description |
|---|---|---|---|
eventsProp | NuiSchedulerEvent<T>[] | [] | The events to show. |
resourcesProp | NuiSchedulerResource[] | [] | Rooms, people or machines: rows of the timeline, and columns of the day and the week. |
viewdefaultViewonViewChangeState | 'month' | 'week' | 'day' | 'agenda' | 'timeline' | 'week' | The view shown. |
viewsProp | NuiSchedulerView[] | all | The 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. |
datedefaultDateonDateChangeState | NuiDate | today | The day shown, and where the keyboard is. Pass defaultDate when a server renders the scheduler: its today may not be the reader’s. |
slotMinutesProp | number | 30 | Minutes per row of the time grid, or per column of a day’s timeline. |
snapMinutesProp | number | slotMinutes | The step events move and resize by. |
dayStart, dayEndProp | number | 0, 24 | The hours the time grid shows, from and to. |
scrollHourProp | number | 8 | The hour the time grid opens at. |
agendaDaysProp | number | 30 | Days the agenda looks ahead. |
businessHoursProp | NuiSchedulerHours[] | Working hours, such as { days: [1, 2, 3, 4, 5], start: '09:00', end: '17:00' }. Other time is shaded. | |
weekendsProp | boolean | true | Shows the weekend. Without it, every view leaves out the locale’s weekend. |
weekNumbersProp | boolean | false | Shows ISO week numbers in the month, and above the times. |
editableProp | boolean | false | Events can be moved and resized, by pointer and keyboard. |
selectableProp | boolean | false | Time can be chosen on the grid, to create events. |
allowProp | (time) => boolean | Decides whether a move, a resize or a choice of time can happen. | |
toolbarProp | boolean | ((toolbar: NuiSchedulerToolbar) => ReactNode) | true | Shows the toolbar, or draws one of your own from what it’s given. |
firstDayProp | 1 … 7 | The first day of the week, 1 for Monday. By default, the locale’s. | |
headingLevelProp | number | 2 | The title’s heading level; the agenda’s days are one deeper. |
localeProp | string | 'en-US' | Formats days and times. |
labelsProp | Partial<NuiSchedulerLabels> | Every text the scheduler shows or announces, to translate. | |
cornersProp | NuiCorners | The shape of its corners: round, squircle, bevel, scoop, notch or square. | |
radiusProp | NuiRadius | How big its corners are: none, small, medium, large or full. | |
densityProp | NuiDensity | How much room it takes: compact, regular or roomy. | |
renderEventRender prop | (event, { time }) => ReactNode | Draws events yourself, from the event and its time as text. | |
renderResourceRender prop | (resource) => ReactNode | Draws the heads of resources yourself. | |
onEventClickCallback | (event: NuiSchedulerEvent<T>) => void | Called with an event clicked, or opened with Enter. | |
onEventChangeCallback | ({ event, start, end, resource? }) => void | Called 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? }) => void | Called with the time chosen on the grid, and its resource. | |
onRangeChangeCallback | ({ start, end }) => void | Called with the first and last day shown when they change, to load their events. | |
refProp | Ref<NuiSchedulerHandle> | What the scheduler’s ref reaches: paging, for a toolbar of your own. | |
previous, next, goTodayMethod | () => void | Show the previous or next page, or today, for a toolbar of your own. | |
titleProperty | string | What’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.
| Name | Type | Default | Description |
|---|---|---|---|
titleProperty | string | What’s shown, as the toolbar’s title says it. | |
view, viewsProperty | NuiSchedulerView, NuiSchedulerView[] | The view shown, and the views offered. | |
setView, previous, next, goTodayMethod | (view?) => void | Switch 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.
| Name | Type | Default | Description |
|---|---|---|---|
id, titleProperty | string | Its key, and what it shows. | |
start, endProperty | NuiDateTime | NuiDate | Dates and times, or dates for all-day events. | |
allDayProperty | boolean | By default, whether start has no time. | |
toneProperty | 'accent' | 'neutral' | 'success' | 'warning' | 'danger' | 'accent' | Its palette. |
color, classProperty | string | Any CSS color, which wins over its tone, and classes to style it with. | |
resourceProperty | string | string[] | The resources it belongs to. | |
rruleProperty | string | A repeat rule from RFC 5545, such as FREQ=WEEKLY;BYDAY=MO. | |
exdateProperty | string[] | Starts of occurrences that don’t happen. | |
recurrenceIdProperty | NuiDateTime | NuiDate | On an occurrence the scheduler reports: the start its rule gave it. | |
editableProperty | boolean | Whether it can be moved, whatever the scheduler says. | |
dataProperty | T | Anything else to keep with it. |
NuiSchedulerResource
A room, a person or a machine that events belong to.
| Name | Type | Default | Description |
|---|---|---|---|
id, titleProperty | string | Its key, and the name it shows. | |
tone, colorProperty | NuiSchedulerTone, string | The colors of its events, unless they have their own. | |
businessHoursProperty | NuiSchedulerHours[] | When it’s available, instead of the scheduler’s working hours. | |
dataProperty | R | Anything else to keep with it. |
Helpers
Functions for repeating events and iCalendar files.
| Name | Type | Default | Description |
|---|---|---|---|
nuiSchedulerOccurrencesMethod | (event, first, last) => NuiSchedulerEvent[] | An event as it shows on the days given: each occurrence of a repeating one. | |
nuiSchedulerRuleMethod | (text: string) => NuiSchedulerRule | null | Reads a repeat rule, or returns null. | |
nuiSchedulerToIcsMethod | (events, options?) => string | Writes events as an iCalendar file. | |
nuiSchedulerFromIcsMethod | (text, { timeZone? }) => NuiSchedulerEvent[] | Reads the events of an iCalendar file, with their times in one time zone. |