Zur Navigation Zum Inhalt Kontakt Menu Trova un componente Descrizione generale Lyne Principi Base Accessibilité Sistema di design Guidelines Deutsch Français Italiano English I nostri principi di design Soluzioni focalizzate sull’utente Riconoscibilità Inclusione Riduzione Olistico Autoesplicativo Orientamento all’attività Adeguatezza Portale della marca FFS Logo Orologio digitale Diritti di utilizzazione Colori die base Colori funzionali Colori Off Brand Icone Icone dell'orario Pittogrammi Informazioni sull’accessibilità Über diesen Guide Contatti Letture consigliate Product Owner User Research Interaction Design Visual Design Development Content Design Testing What is a design system? Designing Coding FAQ Aiuto Processo Contribution Contatto Introduzione Base Componenti Overview Releases Design Tokens Komponenten Roadmap Introduzione Base Informazioni Introduzione Base Componenti Senso & scopo Community Assets Istruzioni Power-Apps Banner pubblicitari digitali SAP Icone delle app Time-Input Info

Was macht die Komponente?

Ein Time-Input ermöglicht es Nutzenden, eine Uhrzeit in einem festgelegten Format einzugeben.

Wann soll die Komponente eingesetzt werden?

  • Um Nutzenden die Eingabe von Uhrzeiten zu ermöglichen, z.B. bei Terminvereinbarungen oder Zeitplänen.
  • Wenn eine genaue Zeiteingabe erforderlich ist, z.B. für Alarme oder Erinnerungen.
  • Um sicherzustellen, dass Uhrzeiten im korrekten Format erfasst werden.

Regeln

  • Eine Validierung der Eingabe soll sicherstellen, dass nur gültige Uhrzeiten akzeptiert werden.
Anatomie
Anatomie der Komponente
Nummer Typ Beschreibung Optional Hinweis
1 Standard-HTML input Nein
1b Standard-HTML input Ja Placeholder
2 Standard-HTML label Ja
3 Komponente sbb-icon Ja Prefix
4 Komponente sbb-icon oder sbb-form-field-clear Ja Suffix
5 Komponente sbb-form-error Nein Datei auswählen
Demo

Spielwiese

This is a required field.
Prefix Nein Ja Suffix Nein Ja Ohne Rahmen Nein Ja Grössen S M L Breite Default Collapse Optional Ja Nein Error Nein Ja Platz für Error reservieren Nein Ja Hintergrund White Milk Iron Charcoal Black
Sbb Time Input Base
Sbb Time Input With Icons
Sbb Time Input Borderless
Sbb Time Input Disabled
Sbb Time Input Readonly
Sbb Time Input With Error
Sbb Time Input Negative
Sbb Time Input With Icons Negative
Sbb Time Input Borderless Negative
Sbb Time Input Disabled Negative
Sbb Time Input Readonly Negative
Sbb Time Input With Error Negative
HTML in Zwischenablage kopiert.
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 "Format example").

The component and the native input can be connected using the input property,
which accepts the id of the native input, or directly its reference.

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

In sbb-form-field

If the sbb-time-input is used within a sbb-form-field:

  • It links to the native input automatically.
  • It adapts to the form-field size.
<sbb-form-field width="collapse" size="s">
  <input value="13:30" />
  <sbb-time-input></sbb-time-input>
</sbb-form-field>

The initial value can be set using the value property (string) of the inputor 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

Events

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

Properties

Name Attribute Privacy Type Default Description
input input public string | HTMLElement | null null Reference of the native input connected to the datepicker.

Methods

Name Privacy Description Parameters Return Inherited From
getValueAsDate public Gets the input value with the correct date format. Date | null
setValueAsDate public Set the input value to the correctly formatted value. date: SbbDateLike void

Events

Name Type Description Inherited From
didChange CustomEvent<void> Deprecated. used for React. Will probably be removed once React 19 is available.
validationChange CustomEvent<SbbValidationChangeEvent> Emits whenever the internal validation state changes.
Trova un componente

Lyne

  • Design Tokens
  • Animation
    Animation
  • Border
    Border
  • Breakpoint
    Breakpoint
  • Color
    Color
  • Layout
    Layout
  • Shadow
    Shadow
  • Size
    Size
  • Spacing
    Spacing
  • Typography
    Typography
  • Action
  • More Info
    Action-Group
  • More Info
    Block-Link
  • More Info
    Button
  • More Info
    Link
  • More Info
    Mini-Button-Group
  • More Info
    Secondary-Button
  • More Info
    Teaser
  • More Info
    Teasser-Hero
  • More Info
    Teaser-Product
  • More Info
    Teaser-Product-Static
  • More Info
    Tertiary-Button
  • More Info
    Transparent-Button
  • Brand
  • More Info
    Clock
  • More Info
    Logo
  • Collection
  • More Info
    Link-List
  • More Info
    Link-List-Anchor
  • More Info
    Skiplink-List
  • More Info
    Table-Wrapper
  • Form
  • More Info
    Autocomplete
  • More Info
    Autocomplete-Grid
  • More Info
    Calendar
  • More Info
    Checkbox
  • More Info
    Checkbox-Group
  • More Info
    Checkbox-Panel
  • More Info
    Datepicker
  • More Info
    File-Selector
  • More Info
    Form-Field
  • More Info
    Radio-Button
  • More Info
    Radio-Button-Group
  • More Info
    Radio-Button-Panel
  • More Info
    Select
  • More Info
    Selection-Expansion-Panel
  • More Info
    Slider
  • More Info
    Toggle
  • More Info
    Toggle-Check
  • Indicator
  • More Info
    Alert
  • More Info
    Alert-Group
  • More Info
    Chip
  • More Info
    Loading-Indicator
  • More Info
    Message
  • More Info
    Notification
  • More Info
    Status
  • More Info
    Stepper
  • More Info
    Tag-Group
  • More Info
    Toast
  • Layout
  • More Info
    Accordion
  • More Info
    Card
  • More Info
    Container
  • More Info
    Divider
  • More Info
    Footer
  • More Info
    Header
  • More Info
    Title
  • Navigation
  • More Info
    Breadcrumb
  • More Info
    Breadcrumb-Group
  • More Info
    Menu
  • More Info
    Navigation
  • More Info
    Tab-Group
  • Overlay
  • More Info
    Dialog
  • More Info
    Overlay
  • More Info
    Popover
  • Time-Table
  • More Info
    Journey-Header
  • More Info
    Pearl-Chain
  • Visual asset
  • More Info
    Icon
  • More Info
    Image
Impressum Contatto Impostazioni dei cookie