Zur Navigation Zum Inhalt Kontakt Menu Komponente finden Übersicht Lyne Prinzipien Grundlagen Barrierefreiheit Design System Guidelines Deutsch Français Italiano English Unsere Gestaltungsprinzipien Nutzerzentriert Wiedererkennbar Inklusiv Reduziert Ganzheitlich Selbsterklärend Aufgabenorientiert Passend SBB Markenportal Logo Digitale Uhr Nutzungsrechte Basis-Farben Funktionale Farben Off-Brand Farben Icons Fahrplan-Icons Piktogramme Über Barrierefreiheit Über diesen Guide Kontakt Weitere Informationen Product Owner User Research Interaction Design Visual Design Development Content Design Testing Was ist ein Design System?​ Designing Coding FAQ Hilfe Prozess Contribution Kontakt Übersicht Basis Komponenten Übersicht Basis Komponenten Übersicht Basis Komponenten Übersicht Releases Design Tokens Komponenten Übersicht Basis Informationen Sinn & Zweck Community Assets Anleitung Power-Apps Digitale Werbebanner SAP App Icons
Komponente finden

Lyne

Basics Animation Animation Border Border Grid Grid Spacings Spacings Typografie Typografie Components Accordion Accordion Action-Group Action-Group Alert Alert Alert-Group Alert-Group Autocomplete Autocomplete Breadcrumb Breadcrumb Breadcrumb-Group Breadcrumb-Group Button Button Calendar Calendar Card Card Card-Action Card-Action Card-Badge Card-Badge Checkbox Checkbox Checkbox-Group Checkbox-Group Chip Chip Clock Clock Container Container Datepicker Datepicker Dialog Dialog Divider Divider Expansion-Panel Expansion-Panel File-Selector File-Selector Footer Footer Form-Error Form-Error Form-Field Form-Field Form-Field-Clear Form-Field-Clear Header Header Header-Action Header-Action Icon Icon Image Image Journey-Header Journey-Header Link Link Link-List Link-List Loading-Indicator Loading-Indicator Logo Logo Menu Menu Menu-Action Menu-Action Message Message Navigation Navigation Navigation-Action Navigation-Action Navigation-List Navigation-List Navigation-Marker Navigation-Marker Navigation-Section Navigation-Section Notification Notification Popover Popover Popover-Trigger Popover-Trigger Radio-Button Radio-Button Radio-Button-Group Radio-Button-Group Select Select Selection-Panel Selection-Panel Signet Signet Skiplink-List Skiplink-List Slider Slider Status Status Sticky-Bar Sticky-Bar 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 Toast Toast Toggle Toggle Toggle-Check Toggle-Check
Button Implementation

The sbb-button component provides the same functionality as a native <button> enhanced with the SBB Design.

<sbb-button>Button text</sbb-button>

Slots

The button text is provided via an unnamed slot; the component can optionally display a sbb-icon
at the component start using the iconName property or via custom content using the icon slot.
At least one is mandatory, so you can have a sbb-button with icon only, text only, or with both.

<sbb-button icon-name="info"> Button text </sbb-button>

<sbb-button>
  <sbb-icon slot="icon" name="info"></sbb-icon>
  Button text
</sbb-button>

<sbb-button icon-name="info" aria-label="Click for more information."></sbb-button>

Link / button properties

The component can be internally rendered as a button or as a link,
depending on the value of the href property, so the associated properties are available
(href, target, rel and download for link; type, name, value and form for button).

If isStatic is set, the component will be rendered as a button without any user interaction.
The isStatic is only considered during initial rendering (connectedCallback), later configuration changes are ignored.
Please note that if the sbb-button is placed inside another anchor or button tag,
it is internally rendered as a span in order to not break HTML functionality.
If the component is placed inside an sbb-form-field, it renders with the correct styling.

<sbb-button href="https://github.com/lyne-design-system/lyne-components" target="_blank">
  Go to site
</sbb-button>

<sbb-button type="button" name="tickets" form="buy" value="tickets"> Buy tickets </sbb-button>

Style

The component has four color variants that can be set using the variant property (default: primary),
and it has also a negative one which can be set using the negative property.

There are two different sizes (m and l, which is the default) that can be set using the size property.

The component can be displayed in disabled state using the self-named property.

<sbb-button variant="secondary">Button</sbb-button>
<sbb-button variant="tertiary">Button</sbb-button>
<sbb-button variant="transparent">Button</sbb-button>

<sbb-button size="m">Button</sbb-button>

<sbb-button disabled>Button</sbb-button>

Focus outline

Please make sure that the focus outline appears in the correct color if the component is used on a dark background.
You can set it by re-defining the css var on sbb-button or any parent element:

sbb-button {
  --sbb-focus-outline-color: var(--sbb-focus-outline-color-dark);
}

Accessibility

Use the accessibility properties in case of an icon-only button to describe the purpose of the sbb-button for screen-reader users.

Properties

Name Attribute Privacy Type Default Description
variant variant public | 'primary' | 'secondary' | 'tertiary' | 'transparent' 'primary' Variant of the button, like primary, secondary etc.
negative negative public boolean false Negative coloring variant flag.
size size public SbbButtonSize 'l' Size variant, either l or m.
isStatic is-static public boolean false Set this property to true if you want only a visual representation of a button, but no interaction (a span instead of a link/button will be rendered).
iconName icon-name public string | undefined The icon name we want to use, choose from the small icon variants from the ui-icons category from here https://icons.app.sbb.ch.
href href public string | undefined The href value you want to link to (if it is present, button becomes a link).
target target public LinkTargetType | string | undefined Where to display the linked URL.
rel rel public string | undefined The relationship of the linked URL as space-separated link types.
download download public boolean | undefined Whether the browser will show the download dialog on click.
type type public ButtonType | undefined The type attribute to use for the button.
disabled disabled public boolean false Whether the button is disabled.
name name public string | undefined The name attribute to use for the button.
value value public string | undefined The value attribute to use for the button.
form form public string | undefined The
element to associate the button with.

Slots

Name Description
Use the unnamed slot to add content to the button.
icon Slot used to display the icon, if one is set
Demo
Label
Varianten Primary Secondary Tertiary Transparent Grössen M L Icon Ja Nein Label Ja Nein Negativ Nein Ja Hintergrund White Milk Iron Charcoal Black
Beispiele Primary
Secondary
Tertiary
Transparent
Primary Negative
Secondary Negative
Tertiary Negative
Transparent Negative
Icon Only
Primary Disabled
Secondary Disabled
Tertiary Disabled
Transparent Disabled
Primary Negative Disabled
Secondary Negative Disabled
Tertiary Negative Disabled
Transparent Negative Disabled
Icon Only Disabled
No Icon
Size M
Fixed Width
With Slotted Icon
Link Opens In New Window
Request Submit
Loading Indicator
HTML-Markup kopiert.
Impressum Kontakt Cookie Einstellungen