Skip to main content

Live Component Playground

Common Examples

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

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

Date Format

The Calendar component accepts ISO 8601 date strings for value and defaultValue. Prefer date-only strings (for example, "2025-07-02") for predictable calendar date selection.onSelection returns a full ISO datetime string with timezone offset (for example, “2025-07-02T00:00:00.000-07:00”), or undefined when the selection is cleared.Convert to a date-only string (for example, const dateOnly = value?.split("T")[0];) before passing the value to date fields or APIs that expect YYYY-MM-DD.

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 June 23, 2026