Zur Navigation Zum Inhalt Kontakt Menu Trouver un composant Aperçu Lyne Principes Bases Accessibilité Système de design Guidelines Deutsch Français Italiano English Nos principes de design Centré sur l’utilisateur Reconnaissable Inclusif Minimaliste Holistique Auto-explicatif Axé sur les tâches Approprié Portail de la marque CFF Logo Horloge numérique Droits d’utilisation Couleurs de base Couleurs fonctionnelles Couleurs off-brand Icônes Icônes de l’horaire Pictogrammes À propos de l’accessibilité À propos de ce guide Contact Informations complémentaires Product Owner User Research Interaction Design Visual Design Development Content Design Testing What is a design system? Conception Développer FAQ Aide Procès Contribution Contact Aperçu Base Composants Aperçu Base Composants Aperçu Base Composants Aperçu Design Tokens Composants Aperçu Base Informations Sens & objectif Community Assets Instructions Power-Apps Bandeaux publicitaires numériques SAP Icônes d’applications
Trouver un composant

Lyne

Basics Animation

Animation

Border

Border

Grid

Grid

Spacings

Spacings

Typografie

Typografie

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

Cette page n'est pas disponible dans la langue souhaitée. Langues disponibles: Deutsch English

Time-Input Implementation

The sbb-time-input is a component that displays the typed value as a formatted time (HH:mm).

The component allows the insertion of up to 4 numbers, possibly with a separator char like ., :, , or -,
then automatically formats the value as time and displays it (see the "Format example" paragraph).

Basically the native input element and the sbb-time-input have to be connected by id reference (see example).
If you use it inside a sbb-form-field, the connection is created automatically.

The initial value can be set using the value property (string) of the input or the setValueAsDate()
method of the sbb-time-input.
When the input changes, if it is valid, the component updates the value of the input. To get the value as a Date object,
the getValueAsDate() method of the sbb-time-input can be called. The date is constructed like following:
the start date is set to 01.01.1970, 00:00:00 UTC, then the typed hours and minuted are added,
e.g.: with a value of 12:34, the getValueAsDate() will be 01.01.1970, 12:34:00 UTC.
If the value is invalid because not real (e.g. 12:61 or 25:30), the component does not format the value,
and will return null if getValueAsDate() was called.

Format example

See the table below for some formatting examples:

Input Output
12:34 12:34
1 01:00
12 12:00
123 01:23
1234 12:34
1. 01:00
1.2 01:02
1.23 01:23
12: 12:00
12.3 12:03
12,34 12:34
12-34 12:34

Validation Change

Whenever the validation state changes (e.g. a valid value becomes invalid or vice versa), the validationChange event is emitted.

Usage

Basic usage:

<input value='13:30' id='input-id'>
<sbb-time-input input='input-id'></sbb-time-input>

Required sbb-time-input inside a sbb-form-field:

<sbb-form-field label='My form' width='collapse'>
<input value='13:30' required>
<sbb-time-input></sbb-time-input>
<sbb-form-error>This field is required!</sbb-form-error>
</sbb-form-field>

Properties

Property Attribute Description Type Default
input input Reference of the native input connected to the datepicker. HTMLElement | string undefined

Events

Event Description Type
didChange [DEPRECATED] only used for React. Will probably be removed once React 19 is available.

CustomEvent<any>
validationChange Emits whenever the internal validation state changes. CustomEvent<ValidationChangeEvent>

Methods

getValueAsDate() => Promise<Date | null>

Gets the input value with the correct date format.

Returns

Type: Promise<Date>

setValueAsDate(date: Date | number | string) => Promise<void>

Set the input value to the correctly formatted value.

Returns

Type: Promise<void>


Demo
This is a required field.
Nein Ja
Nein Ja
Nein Ja
M L
Default Collapse
Ja Nein
Nein Ja
Nein Ja
White Milk Iron Charcoal Black
Mehr Beispiele auf Storybook
Impressum Contact Paramètres des cookies