A button is an interactive element that triggers an action when it is clicked.
Number | Type | Description | Optional | Info |
---|---|---|---|---|
1 | Component | sbb-icon | Yes | Ein Icon oder ein Label ist zu setzen. |
2 | Text | Label | Yes | Ein Icon oder ein Label ist zu setzen. |
The sbb-transparent-button
component provides the same functionality as a native <button>
enhanced with the SBB Design in the 'transparent' variant.
<sbb-transparent-button>Button text</sbb-transparent-button>
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-transparent-button
with icon only, text only, or with both.
<sbb-transparent-button icon-name="info"> Button text </sbb-transparent-button>
<sbb-transparent-button>
<sbb-icon slot="icon" name="info"></sbb-icon>
Button text
</sbb-transparent-button>
<sbb-transparent-button
icon-name="info"
aria-label="Click for more information."
></sbb-transparent-button>
The component is internally rendered as a button,
accepting its associated properties (type
, name
, value
and form
).
<sbb-transparent-button type="submit" name="tickets" form="buy" value="tickets">
Buy tickets
</sbb-transparent-button>
The component has a negative variant 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-transparent-button negative>Button</sbb-transparent-button>
<sbb-transparent-button size="m">Button</sbb-transparent-button>
<sbb-transparent-button disabled>Button</sbb-transparent-button>
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-transparent-button
or any parent element:
sbb-transparent-button {
--sbb-focus-outline-color: var(--sbb-focus-outline-color-dark);
}
Use the accessibility properties in case of an icon-only button to describe the purpose of the sbb-transparent-button
for screen-reader users.
Name | Attribute | Privacy | Type | Default | Description |
---|---|---|---|---|---|
disabled | disabled | public | boolean | false | Whether the component is disabled. |
form | form | public | string | undefined | The | |
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. | |
name | name | public | string | The name of the button element. | |
negative | negative | public | boolean | false | Negative coloring variant flag. |
size | size | public | SbbButtonSize | undefined | 'l' | Size variant, either l or m. |
type | type | public | SbbButtonType | 'button' | The type attribute to use for the button. |
value | value | public | string | The value of the button element. |
Name | Description |
---|---|
Use the unnamed slot to add content to the transparent-button. | |
icon | Slot used to display the icon, if one is set |