createCalendar API
Related
Explore these related pages for additional context and usage patterns.
| Page | Category |
|---|---|
| createCalendar | Forms |
| useDate | Plugins |
| createInput | Forms |
Functions
createCalendar
(options?: CalendarOptions<Z>) => CalendarContextOptions
adapter
DateAdapter<Z> | undefinedDate engine. Omit it to borrow an installed date plugin, or to use
V0PlainDateAdapter when none is installed. An adapter you pass is not
replaced, and its firstDayOfWeek is not written.
month
MaybeRefOrGetter<string | undefined>Visible month. YYYY-MM, or a day whose month is used. Omitted means the
current month, clamped to min and max. A writable ref is written as
YYYY-MM when the grid pages. Inside a component it is also written when
min or max clamps the month it opened on. A day token stays while the
page stays in that month. A getter or a readonly ref is not written.
value
MaybeRefOrGetter<CalendarValue>Selected day, or { start, end } in range mode. A ref is written back.
A getter or a readonly ref is not. Inside a component, changing mode
clears it.
mode
MaybeRefOrGetter<CalendarMode> | undefined'single' selects one day. 'range' selects a start and an end.
A ref or getter is read on each interaction. Inside a component, changing
it clears the selection.
Default: 'single'
disabled
MaybeRefOrGetter<CalendarDisabled> | undefinedtrue disables every day. An array of YYYY-MM-DD days disables those
days. A function disables the days it returns true for. A bare function is
the predicate and is called with the ISO day, not passed through toValue.
Navigation still runs.
Default: false
readonly
MaybeRefOrGetter<boolean> | undefinedselect and unselect no-op. Cells stay enabled, and paging still runs.
Default: false
firstDayOfWeek
MaybeRefOrGetter<number | undefined>Week start. 0 is Sunday. A finite number wins and is not written onto
the adapter. Omit it to follow the adapter, or an owned locale.
mandatory
MaybeRefOrGetter<boolean> | undefinedIn single mode, clicking the selected day again does not clear it.
Another day still replaces it. unselect() no-ops. Range clicks ignore
this. Nothing is selected until the caller selects a day.
Default: false
locale
MaybeRefOrGetter<string | undefined>BCP 47 tag. Written onto the adapter only when this call constructs it, which moves the weekday columns and the month label. A borrowed adapter keeps its own locale.
Properties
focused
Readonly<Ref<string, string>>YYYY-MM-DD navigation follows. May sit on a disabled in-month day.
Methods
select
(iso: string) => voidSelects an in-month day that is not disabled.
In single mode, a second click on that day clears it, unless mandatory is set.
In range mode, a later click sets the end or starts a new range.
move
(unit: CalendarUnit, amount: number) => voidWalks the focused day and pages when it leaves the month.
A step past min or max lands on that wall.