Zur Navigation Zum Inhalt Kontakt Menu Find component Overview Lyne Principles Foundation Accessibility Design System Guidelines Deutsch Français Italiano English Our design principles User-centred Recognisable Inclusive Reduced Holistic Self-explanatory Task-oriented Appropriate SBB Brand portal Logo Digital clock Rights of use Base colors Functional colors Off brand colors Icons Timetable icons Pictograms About accessibility Über diesen Guide Contact Further information Product Owner User Research Interaction Design Visual Design Development Content Design Testing What is a design system? Designing Coding FAQ Help Process Contribution Contact Overview Base Components Overview Base Components Overview Base Components Overview Design Tokens Components Overview Base Informationen Sense & Purpose Community Assets Instructions Power-Apps Digital banner ads SAP Design Guidelines App Icons
Find component

Lyne

Basics Animation

Animation

Border

Border

Grid

Grid

Spacings

Spacings

Typography

Typography

Components Action-Group

Action-Group

Alert

Alert

Alert-Group

Alert-Group

Autocomplete

Autocomplete

Button

Button

Calendar

Calendar

Card

Card

Card-Badge

Card-Badge

Checkbox

Checkbox

Checkbox-Group

Checkbox-Group

Chip

Chip

Clock

Clock

Datepicker

Datepicker

Dialog

Dialog

Divider

Divider

Footer

Footer

Form-Error

Form-Error

Form-Field

Form-Field

Header

Header

Header-Action

Header-Action

Icon

Icon

Image

Image

Journey-Header

Journey-Header

Link

Link

Link-List

Link-List

Logo

Logo

Menu

Menu

Menu-Action

Menu-Action

Radio-Button

Radio-Button

Radio-Button-Group

Radio-Button-Group

Selection-Panel

Selection-Panel

Signet

Signet

Slider

Slider

Tab-Group

Tab-Group

Tab Title

Tab Title

Tag

Tag

Tag-Group

Tag-Group

Teaser

Teaser

Teaser-Hero

Teaser-Hero

Time-Input

Time-Input

Title

Title

Toggle

Toggle

Toggle-Check

Toggle-Check

Tooltip

Tooltip

Tooltip-Trigger

Tooltip-Trigger

Calendar Implementation

The sbb-calendar component displays a calendar that allows the user to select a date. For accessibility purposes it's rendered as a native table element and each day is a button.

While being deeply linked to the implementation of the sbb-datepicker-toggle component, it can be used on its own.

For date inputs (min, max, selected-date) the accepted formats are:

  • Date objects
  • ISO String
  • Unix Timestamp (number of seconds since 1 Jan 1970)

and it's recommended to set the time to 00:00:00.

The component displays one month by default; two months can be displayed setting the wide property to true. It's also
possible to filter out unwanted date using the dateFilter function property.

Consumers can listen to the dateSelected event on the sbb-calendar component to intercept the selected date
which can be read from event.detail.

Note that using the dateFilter function as a replacement for the min and max properties will most likely result in a significant loss of performance.

Accessibility

Keyboard navigation summary:

  • Left arrow: go to previous day
  • Right arrow: go to next day
  • Up arrow: go to the same day in the previous week
  • Down arrow: go to the same day in the next week
  • Home: go to the first day of the month
  • End: go to the last day of the month
  • Page Up: go to the top of the column of the currently selected day
  • Page Down: go to the bottom of the column of the currently selected day

Usage

Calendar with selected date and bounds:

<sbb-calendar 
min="1600000000"
max="1700000000"
selected-date="1650000000"
>
</sbb-calendar>

Testing

To specify a specific date for the current datetime, you can use the data-now attribute (timestamp in milliseconds).
This is helpful if you need a specific state of the component.

Properties

Property Attribute Description Type Default
dateFilter -- A function used to filter out dates. (date: Date) => boolean () => true
max max The maximum valid date. Takes Date Object, ISOString, and Unix Timestamp (number of seconds since Jan 1 1970). Date | number | string undefined
min min The minimum valid date. Takes Date Object, ISOString, and Unix Timestamp (number of seconds since Jan 1 1970). Date | number | string undefined
selectedDate selected-date The selected date. Takes Date Object, ISOString, and Unix Timestamp (number of seconds since Jan 1 1970). Date | number | string undefined
wide wide If set to true, two months are displayed boolean false

Events

Event Description Type
date-selected Event emitted on date selection. CustomEvent<Date>

Methods

resetPosition() => Promise<void>

Resets the active month according to the new state of the calendar.

Returns

Type: Promise<void>

Dependencies

Used by

Depends on

Graph

graph TD;
sbb-calendar --> sbb-button
sbb-button --> sbb-icon
sbb-datepicker-toggle --> sbb-calendar
style sbb-calendar fill:#f9f,stroke:#333,stroke-width:4px

Demo
No Yes
White Milk Iron Charcoal Black
More examples on Storybook
Imprint Contact Cookie settings