Concepts
Anatomy
The parts a calendar is built from, and their names in code.
A calendar is made of the parts your createCalendar factory returns, such as Calendar.Toolbar,
and a few components from the registry. The diagram labels each part with its name in code, and the
code below it puts the same parts together.
- Root
Calendar.Root - Frame
Calendar.Frame - Toolbar
Calendar.Toolbar - Today
Calendar.TodayTrigger - Previous
Calendar.PreviousTrigger - Next
Calendar.NextTrigger - Title
Calendar.Title - View switcher
ViewSwitcher - Mini month
MiniMonth - Viewport
Calendar.Viewport - Active view
Calendar.ActiveView
<Calendar.Root
events={meetings}
defaultAnchorDate={today}
defaultTimeZone="Europe/Berlin"
locale="en-US"
weekRules={weekRules}
>
<Calendar.Frame>
<Calendar.Toolbar>
<Calendar.TodayTrigger>Today</Calendar.TodayTrigger>
<Calendar.PreviousTrigger aria-label="Previous period" />
<Calendar.NextTrigger aria-label="Next period" />
<Calendar.Title />
<ViewSwitcher value={view} onValueChange={setView} options={viewOptions} />
</Calendar.Toolbar>
<aside>
<MiniMonth
locale="en-US"
selectedDate={anchorDate}
onSelectDate={setAnchorDate}
today={today}
weekStartsOn={1}
/>
</aside>
<Calendar.Viewport>
<Calendar.ActiveView />
</Calendar.Viewport>
</Calendar.Frame>
</Calendar.Root>Rootholds the calendar's state and renders no element of its own. Every part and hook works anywhere inside it.Frame,Toolbar,Title,Viewport, and the three triggers each render one element with adata-calendar-partattribute, such asdata-calendar-part="today-trigger", for styling. The component reference lists them.ActiveViewrenders the active view's Renderer inside the viewport.ViewSwitcherandMiniMonthcome fromregistry/calendar. They're plain components: you connect them to the calendar withsetView,setAnchorDate, and theviewandanchorDatestate.Calendar.ViewSwitcheris an unstyled<select>you can use instead.
The registry's CalendarToolbar renders the toolbar parts above, styled, and puts its children at
the end. The Quick start uses it:
<CalendarToolbar calendar={Calendar}>
<ViewSwitcher value={view} onValueChange={setView} options={viewOptions} />
</CalendarToolbar>Views
ActiveView draws the rest. Each built-in view has its own anatomy:
Edit on GitHub
Last updated on