Calendar
Calendars display a grid of days in one or more months and allow users to select a single date.
Example

Date types
The calendar accepts the following date types as inputs:
NoneLocalDateZoneDateTimeInstantintstrdatetime.datetimenumpy.datetime64pandas.Timestamp
The input will be converted to one of three Java date types:
LocalDate: A LocalDate is a date without a time zone in the ISO-8601 system, such as “2007-12-03” or “2057-01-28”.Instant: An Instant represents an unambiguous specific point on the timeline, such as 2021-04-12T14:13:07 UTC.ZonedDateTime: A ZonedDateTime represents an unambiguous specific point on the timeline with an associated time zone, such as 2021-04-12T14:13:07 America/New_York.
The format of the calendar and the type of the value passed to the on_change handler
is determined by the type of the following props in order of precedence:
valuedefault_valuefocused_valuedefault_focused_value
If none of these are provided, the on_change handler passes a range of Instant.
Value
A Calendar has no selection by default. An initial, uncontrolled value can be provided to the Calendar using the default_value prop. Alternatively, a controlled value can be provided using the value prop.
Labeling
An aria_label must be provided to the Calendar for accessibility. If it is labeled by a separate element, an aria_labelledby prop must be provided using the id of the labeling element instead.
Events
Calendar accepts an on_change prop which is triggered whenever a date is selected by the user.
Validation
By default, Calendar allows selecting any date. The min_value and max_value props can also be used to prevent the user from selecting dates outside a certain range.
This example only accepts dates after today.
Controlling the focused date
By default, the selected date is focused when a Calendar first mounts. If no value or default_value prop is provided, then the current date is focused. However, Calendar supports controlling which date is focused using the focused_value and on_focus_change props. This also determines which month is visible. The default_focused_value prop allows setting the initial focused date when the Calendar first mounts, without controlling it.
This example focuses July 1, 2021 by default. The user may change the focused date, and the on_focus_change event updates the state. Clicking the button resets the focused date back to the initial value.
Disabled state
The is_disabled prop disables the calendar to prevent user interaction. This is useful when the calendar should be visible but not available for selection.
Read only
The is_read_only prop makes the calendar’s value immutable. Unlike is_disabled, the calendar remains focusable.
Visible Months
By default, the Calendar displays a single month. The visible_Months prop allows displaying up to 3 months at a time.
Page Behavior
By default, when pressing the next or previous buttons, pagination will advance by the visible_months value. This behavior can be changed to page by single months instead, by setting page_behavior to single.
Time table filtering
Calendars can be used to filter tables with time columns.
API Reference
A calendar allows the user to select a date.
Returns: Element The calendar element.
| Parameters | Type | Default | Description |
|---|---|---|---|
| value | DType | None | str | date | datetime | datetime64 | Timestamp | int | UndefinedType | <deephaven.ui.types.types.UndefinedType object> | The current value (controlled). |
| default_value | DType | None | str | date | datetime | datetime64 | Timestamp | int | UndefinedType | <deephaven.ui.types.types.UndefinedType object> | The default value (uncontrolled). |
| focused_value | DType | None | str | date | datetime | datetime64 | Timestamp | int | None | Controls the currently focused date within the calendar. |
| default_focused_value | DType | None | str | date | datetime | datetime64 | Timestamp | int | None | The date that is focused when the calendar first mounts (uncountrolled). |
| min_value | DType | None | str | date | datetime | datetime64 | Timestamp | int | None | The minimum allowed date that a user may select. |
| max_value | DType | None | str | date | datetime | datetime64 | Timestamp | int | None | The maximum allowed date that a user may select. |
| page_behavior | Literal['single', 'visible'] | None | None | Controls the behavior of paging. Pagination either works by advancing the visible page by visibleDuration (default) or one unit of visibleDuration. |
| is_invalid | bool | None | None | Whether the current selection is invalid according to application logic. |
| is_disabled | bool | None | None | Whether the input is disabled. |
| is_read_only | bool | None | None | Whether the input can be selected but not changed by the user. |
| auto_focus | bool | None | None | Whether the element should receive focus on render. |
| error_message | Element | None | None | An error message for the field. |
| visible_months | int | None | None | The number of months to display at once. Up to 3 months are supported. |
| key | str | None | None | A unique identifier used by React to render elements in a list. |