Skip to main content

Calendar

<ui5-calendar> | Since 1.0.0-rc.11

The ui5-calendar component allows users to select one or more dates.

Currently selected dates are represented with instances of ui5-date as children of the ui5-calendar. The value property of each ui5-date must be a date string, correctly formatted according to the ui5-calendar's formatPattern property. Whenever the user changes the date selection, ui5-calendar will automatically create/remove instances of ui5-date in itself, unless you prevent this behavior by calling preventDefault() for the selection-change event. This is useful if you want to control the selected dates externally.

Usage​

The user can navigate to a particular date by:

  • Pressing over a month inside the months view
  • Pressing over an year inside the years view

The user can confirm a date selection by pressing over a date inside the days view.

Keyboard Handling​

The ui5-calendar provides advanced keyboard handling. When a picker is showed and focused the user can use the following keyboard shortcuts in order to perform a navigation:

  • Day picker:

  • [F4] - Shows month picker

  • [Shift] + [F4] - Shows year picker

  • [Page Up] - Navigate to the previous month

  • [Page Down] - Navigate to the next month

  • [Shift] + [Page Up] - Navigate to the previous year

  • [Shift] + [Page Down] - Navigate to the next year

  • [Ctrl] + [Shift] + [Page Up] - Navigate ten years backwards

  • [Ctrl] + [Shift] + [Page Down] - Navigate ten years forwards

  • [Home] - Navigate to the first day of the week

  • [End] - Navigate to the last day of the week

  • [Ctrl] + [Home] - Navigate to the first day of the month

  • [Ctrl] + [End] - Navigate to the last day of the month

  • Month picker:

  • [Page Up] - Navigate to the previous year

  • [Page Down] - Navigate to the next year

  • [Home] - Navigate to the first month of the current row

  • [End] - Navigate to the last month of the current row

  • [Ctrl] + [Home] - Navigate to the first month of the current year

  • [Ctrl] + [End] - Navigate to the last month of the year

  • Year picker:

  • [Page Up] - Navigate to the previous year range

  • [Page Down] - Navigate the next year range

  • [Home] - Navigate to the first year of the current row

  • [End] - Navigate to the last year of the current row

  • [Ctrl] + [Home] - Navigate to the first year of the current year range

  • [Ctrl] + [End] - Navigate to the last year of the current year range

Fast Navigation​

This component provides a build in fast navigation group which can be used via [F6] / [Shift] + [F6] / [Ctrl] + [Alt/Option] / [Down] or [Ctrl] + [Alt/Option] + [Up]. In order to use this functionality, you need to import the following module: import "@ui5/webcomponents-base/dist/features/F6Navigation.js"

Calendar types​

The component supports several calendar types - Gregorian, Buddhist, Islamic, Japanese and Persian. By default the Gregorian Calendar is used. In order to use the Buddhist, Islamic, Japanese or Persian calendar, you need to set the primaryCalendarType property and import one or more of the following modules:

import "@ui5/webcomponents-localization/dist/features/calendar/Buddhist.js";

import "@ui5/webcomponents-localization/dist/features/calendar/Islamic.js";

import "@ui5/webcomponents-localization/dist/features/calendar/Japanese.js";

import "@ui5/webcomponents-localization/dist/features/calendar/Persian.js";

Or, you can use the global configuration and set the calendarType key:

<script data-id="sap-ui-config" type="application/json">
{
"calendarType": "Japanese"
}
</script>

ES6 Module Import​

import "@ui5/webcomponents/dist/Calendar.js";

Basic Sample​

Properties​

selectionMode​

DescriptionDefines the type of selection used in the calendar component. Accepted property values are:
- CalendarSelectionMode.Single - enables a single date selection.(default value)
- CalendarSelectionMode.Range - enables selection of a date range.
- CalendarSelectionMode.Multiple - enables selection of multiple dates.
Type"Single" | "Multiple" | "Range"
Default"Single"

hideWeekNumbers​

DescriptionDefines the visibility of the week numbers column.
Note: For calendars other than Gregorian, the week numbers are not displayed regardless of what is set.
Typeboolean
Defaultfalse

primaryCalendarType​

DescriptionSets a calendar type used for display. If not set, the calendar type of the global configuration is used.
Type"Gregorian" | "Islamic" | "Japanese" | "Buddhist" | "Persian" | undefined
Defaultundefined

secondaryCalendarType​

DescriptionDefines the secondary calendar type. If not set, the calendar will only show the primary calendar type.
Type"Gregorian" | "Islamic" | "Japanese" | "Buddhist" | "Persian" | undefined
Defaultundefined
Since1.0.0-rc.16

formatPattern​

DescriptionDetermines the format, displayed in the input field.
Typestring | undefined
Defaultundefined

minDate​

DescriptionDetermines the minimum date available for selection.
Note: If the formatPattern property is not set, the minDate value must be provided in the ISO date format (YYYY-MM-dd).
Typestring
Default""
Since1.0.0-rc.6

maxDate​

DescriptionDetermines the maximum date available for selection.
Note: If the formatPattern property is not set, the maxDate value must be provided in the ISO date format (YYYY-MM-dd).
Typestring
Default""
Since1.0.0-rc.6

calendarWeekNumbering​

DescriptionDefines how to calculate calendar weeks and first day of the week. If not set, the calendar will be displayed according to the currently set global configuration.
Type"Default" | "ISO_8601" | "MiddleEastern" | "WesternTraditional"
Default"Default"
Since2.2.0

Slots​

calendarLegend​

DescriptionDefines the calendar legend of the component.
TypeArray<CalendarLegend>
Since1.23.0

default​

DescriptionDefines the selected date or dates (depending on the selectionMode property) for this calendar as instances of ui5-date or ui5-date-range. Use ui5-date for single or multiple selection, and ui5-date-range for range selection.
TypeArray<ICalendarSelectedDates>

specialDates​

DescriptionDefines the special dates, visually emphasized in the calendar.
TypeArray<SpecialCalendarDate>
Since1.23.0

Events​

selection-change​

DescriptionFired when the selected dates change.
Note: If you call preventDefault() for this event, the component will not create instances of ui5-date for the newly selected dates. In that case you should do this manually.
TypeCustomEvent<CalendarSelectionChangeEventDetail>
ParametersselectedValues: Array<string>
The selected dates
selectedDates: Array<number>
The selected dates as UTC timestamps
BubblesYes
CancelableYes - via preventDefault()

Methods​

No methods available for this component.

CSS Parts​

NameDescription
day-cellUsed to style the day cells.
day-cell-selectedUsed to style the day cells when selected.
day-cell-selected-betweenUsed to style the day cells in between of selected dates in range.
month-cellUsed to style the month cells.
month-cell-selectedUsed to style the month cells when selected.
month-cell-selected-betweenUsed to style the day cells in between of selected months in range.
year-cellUsed to style the year cells.
year-cell-selectedUsed to style the year cells when selected.
year-cell-selected-betweenUsed to style the day cells in between of selected years in range.

More Samples​

Selection Modes​

The Calendar supports Single, Multiple and Range selection.

Min and Max Dates​

Define min and max date boundaries to contrain user choice.

Calendar Types​

Several calendars are supported: Gregorian, Islamic, Persian and Japanese.

Calendar with Legend​

You can use the CalendarLegend component in addition to the Calendar to highlight specific days. Discover all the available CalendarLegendItem Types.

Timezones​

You can set to the configuration the preferred time zone, such as: Asia/Tokyo, Pacific/Apia, Asia/Kolkata, Europe/Sofia and etc.

CalendarWeekNumbering​

You can use the component, the preferred week numbering and first day of week.