Calendar

The Calendar component displays a month view that lets users browse and select a date. It supports min/max constraints, disabled dates, indicator dates, week numbers and locale-aware formatting, and can be used standalone or embedded in other components such as the Date Field.

UsageCodeAccessibility
  <sl-calendar aria-label="Choose exam date"></sl-calendar>

When to use

The following guidance describes when to use the calendar component.

Visual date selection

Use the Calendar when users benefit from seeing dates in a full month view. This is useful when context such as weekdays, weekends, holidays, deadlines, or already booked days helps users make a clear date choice.

Browsing dates

Use the Calendar when users need to browse and orient themselves in time, for example to check which weekday a date falls on or to navigate between months and years before selecting a date.

Date navigation

Use the Calendar anywhere users need to navigate through dates and make a selection. This is useful when users need to move between months or years, explore available dates, or choose a date within a broader date-based workflow.

When not to use

The Calendar may not be the best choice in the following scenarios:

Date selection

Calendar is a standalone date navigation component designed for browsing and navigating days, months, and years in date-related content, rather than for simple date entry or relative timeframe selection. Use the Date Field when users need to enter a specific date, and use radio buttons, a segmented control, or a select for relative periods.

Anatomy

ItemNameDescriptionOptional
1HeaderDisplays the current month and year and the navigation controls.no
2Navigation buttonsMove to the previous or next month (and optionally year).no
3Weekday rowLocalized day-of-week labels.no
4Week numbersISO week numbers next to each row.yes
5GridGrid of selectable days, month or year visible.yes
6Today indicatorVisual marker for today's date.yes
7Indicator datesVisual markers for highlighted dates (e.g. events).yes

States

  • Idle: No date selected or with a selected date highlighted.
  • Hover: Visual hover effects on focusable days.
  • Focus: Display the focus ring on the focused day.
  • Selected: Highlighted styling on the selected date.
  • Disabled day: Days outside min / max or in disabled-dates are styled as non-selectable.
  • Disabled (whole calendar): Non-interactive, muted.
  • Read-only: Visible state, no interaction.

Figma Properties

These properties describe the Figma setup for the Calendar. Some properties represent real component behaviour, while others are only used to preview or compose the component in Figma.

sl-calendar

Main component used to compose the Calendar and preview its available views.

ItemOptionsDescription
ViewDays Months YearsSwitches the Calendar preview between day, month, and year selection views.
FooterbooleanFigma-only composition property. The footer is not part of the current code component and should move to the Date Field or Range Field Picker composition.

cal-header

Nested header component used to preview which view-switching buttons are available in the Calendar header.

ItemOptionsDescription
Month ButtonbooleanShows or hides the month button in the Calendar header.
Year ButtonbooleanShows or hides the year button in the Calendar header.
Decade ButtonbooleanShows or hides the decade button in the Calendar header.

date-cal-days_grid

Nested day grid component used to preview the day view layout.

ItemOptionsDescription
Weeks NumberbooleanShows or hides week numbers in the day grid.

cal-months_grid

Nested month grid component used to compose the month selection view.

ItemOptionsDescription
Month gridnested componentDisplays selectable months when the Calendar is shown in the month view. No exposed Figma property was provided in the current screenshots.

cal-years_grid

Nested year grid component used to compose the year selection view.

ItemOptionsDescription
Year gridnested componentDisplays selectable years when the Calendar is shown in the year view. No exposed Figma property was provided in the current screenshots.

Behavior

Selecting a date

Click a day or focus it with the keyboard and press Enter / Space to select it.

Use the navigation buttons in the header to move between months and years. In the calendar grid, use arrow keys to move by day or week, and Home / End to move to the first or last focusable day in the grid.

Day indicators

Calendar day buttons can display different visual indications to help users understand the status of a date. When show-today is set, today's date is visually highlighted to help users orient themselves in the current month. Dates included in indicator-dates display a visual marker without changing their interactivity, which is useful for highlighting events, deadlines, or notifications. Dates included in disabled-dates, or dates outside the configured min and max range, remain visible in the grid but are shown as unavailable and cannot be selected.

  • Date Field: Input field that combines free typing with a calendar popover.
  • Time Field: Companion component for selecting a time.
  <sl-calendar aria-label="Choose a course start date" show-today show-week-numbers></sl-calendar>

Localization

Month names, day names and the first day of the week follow the active locale (via Intl.DateTimeFormat).

You can override the first day of the week with the first-day-of-week attribute (0 for Sunday, 1 for Monday, etc.).

Calendar API

Calendar component that combines day, month and year selection views to pick a date. Used internally by the date field, but can also be used standalone.

Properties

NameAttributeTypeDefaultDescription
disabledDatesdisabled-datesDate[] | undefinedThe list of dates that should be set as disabled.
firstDayOfWeekfirst-day-of-weeknumber | undefinedThe first day of the week; 0 for Sunday, 1 for Monday.
indicatorDatesindicator-datesIndicator[] | undefinedThe list of dates that should display an indicator. Each item has a date and optional color and label values that are used to improve accessibility. Use indicator-dates to highlight specific dates with a visual indicator (for example, exam dates or assignment deadlines) without disabling them.
localelocalestringThe component's locale.
maxmaxDate | undefinedundefinedThe maximum date selectable in the calendar. Dates outside the range are visually disabled and cannot be selected.
minminDate | undefinedundefinedThe minimum date selectable in the calendar. Dates outside the range are visually disabled and cannot be selected.
monthmonthDate | undefinedThe month that the calendar opens on.
readonlyreadonlyboolean | undefinedWill disable the ability to select a date when set.
selectedselectedDate | undefinedThe selected date.
showTodayshow-todayboolean | undefinedHighlights today's date when set.
showWeekNumbersshow-week-numbersboolean | undefinedShows the week numbers.

Events

NameEvent typeDescription
sl-changeSlChangeEvent<Date>Emits when the value changes.

Month view API

A component that renders a single month grid without navigation controls. Used internally by sl-select-day and can be used to compose custom calendar layouts.

Properties

NameAttributeTypeDefaultDescription
disabledDatesdisabled-datesDate[] | undefinedThe list of dates that should be disabled.
firstDayOfWeekfirst-day-of-weeknumber1The first day of the week; 0 for Sunday, 1 for Monday.

NOTE: Remove this property once Intl.Locale.prototype.getWeekInfo is widely available. See https://caniuse.com/mdn-javascript_builtins_intl_locale_getweekinfo

getDayLabel-Returns the default aria-label for a given day.
getDayParts-Returns an array of part names for a given day.
hideDaysOtherMonthshide-days-other-monthsboolean | undefinedfalseWill only show the days of the current month, not the next or previous, when true.
indicatorDatesindicator-datesIndicator[] | undefinedThe list of dates that should display an indicator. Each item is an Indicator with a date, an optional color and label that is used to improve accessibility (added as a tooltip). Use indicator-dates to highlight specific dates with a visual indicator (for example, exam dates or assignment deadlines) without disabling them.
localelocalestringThe component's locale.
maxmaxDate | undefinedundefinedThe maximum date selectable in the month. Dates outside the range are visually disabled and cannot be selected.
minminDate | undefinedundefinedThe minimum date selectable in the month. Dates outside the range are visually disabled and cannot be selected.
monthmonthDatenew Date()The current month to display.
readonlyreadonlyboolean | undefinedfalseIf set, will not render buttons for each day.
renderer-MonthViewRenderer | undefinedYou can customize how a day is rendered by providing a custom renderer callback.
selectedselectedDate | undefinedundefinedThe selected date.
showTodayshow-todayboolean | undefinedfalseHighlights today's date when set.
showWeekNumbersshow-week-numbersboolean | undefinedfalseWill render a column with the week numbers when true.

Methods

NameParametersReturnDescription
renderHeaderTemplateResultRenders the header row with week day names. Override this to customize the header.
renderDayday: DayTemplateResultRenders a single day cell. You can also use the renderer property to customize how days look.

Events

NameEvent typeDescription
sl-changeSlChangeEvent<Date>Emits when the user uses the keyboard to navigate to the next/previous month.
sl-selectSlSelectEvent<Date>Emits when the user selects a day.

CSS Parts

NameDescription
dayThe day button.
disabledThe day button when shown as disabled.
headerThe thead element with weekday names.
indicatorThe day button for a date with an indicator.
indicator-blueThe day button for a date with a blue indicator.
indicator-redThe day button for a date with a red indicator.
indicator-yellowThe day button for a date with a yellow indicator.
indicator-greenThe day button for a date with a green indicator.
indicator-greyThe day button for a date with a grey indicator.
next-monthThe day button for a day in the next month.
out-of-rangeThe day button for a date outside the min/max range.
previous-monthThe day button for a day in the previous month.
selectedThe day button for the selected date.
todayThe day button for today's date.
week-dayThe week day header cell.
week-numberThe week number cell.

Keyboard interactions

The calendar supports keyboard navigation through the month view.

CommandDescription
TabMoves focus into and out of the calendar grid and the month/year navigation controls.
Arrow Left/RightMoves focus to the previous or next day.
Arrow Up/DownMoves focus to the same day in the previous or next week.
Home/EndMoves focus to the first or last focusable day in the calendar grid.
Enter/SpaceSelects the currently focused date.

WAI-ARIA

In the component itself we use multiple aria-attributes to assure the component works well with a range of assistive technologies. For some attributes however it is not possible for the Design System to add a meaningful value, because it relies on the context or way a component is used.

Attributes that we recommend you add in certain scenarios are mentioned below.

AttributeValueDescription
aria-labelstringDefines a string that labels the calendar. Useful when the calendar is used standalone, without a surrounding labelled control.
aria-labelledbystringReferences the ID of the element that labels the calendar.
Interactive example