Skip to main content

Live Component Playground

Common Examples

import { Calendar } from "@servicetitan/anvil2";

function ExampleComponent() {
  return <Calendar defaultValue={new Date().toISOFormat()} />;
}

Date Format

To follow the international standard, the Anvil2 Calendar component uses ISO 8601 for date-time format. ISO date format strings should always be used when passing a date-time value to a Calendar. The same format is also returned by the onSelection callback.

Example with new Date()

<Calendar defaultValue={new Date().toISOString()} />

Controlling calendar state

Uncontrolled calendars

By default, calendars handle their own state. Use the defaultValue prop to set the initial value of an uncontrolled calendar.

Controlled calendars

Use the value prop to manually control the state of a calendar.

Selecting a date range

Calendar can also be used to select range of dates using range prop.

Calendar focus

By default, the month of selected date or today is shown.

Overriding calendar focus

In the example below, 2024-07-07 is the selected date but June is showing on initial render because of focusedDate="2024-06-06".

Calendar Timezone

By default, local browser timezone is used. To override local system timezone, defaultTimezone can be used.

Scoping calendar dates

There are two different ways to limit the scope of selectable dates within a calendar.

Min and Max

The minDate and maxDate props can be used to scope the date range selection.

Unavailable dates

You can also pass an array of dates to the unavailable.dates prop to disable selecting specific dates.
Last modified on January 23, 2026