ToggleButton

@ui5/webcomponents
<ui5-togglebutton>

ToggleButton States

ToggleButton Pressed ToggleButton Disabled ToggleButton Disabled ToggleButton Accept ToggleButton Accept ToggleButton Reject ToggleButton Reject ToggleButton Transparent ToggleButton Transparent ToggleButton
<ui5-togglebutton>ToggleButton</ui5-togglebutton>
<ui5-togglebutton pressed>Pressed ToggleButton</ui5-togglebutton>
<ui5-togglebutton disabled>Disabled ToggleButton</ui5-togglebutton>
<ui5-togglebutton disabled pressed>Disabled ToggleButton</ui5-togglebutton>
<ui5-togglebutton design="Positive">Accept ToggleButton</ui5-togglebutton>
<ui5-togglebutton design="Positive" pressed>Accept ToggleButton</ui5-togglebutton>
<ui5-togglebutton design="Negative">Reject ToggleButton</ui5-togglebutton>
<ui5-togglebutton design="Negative" pressed>Reject ToggleButton</ui5-togglebutton>
<ui5-togglebutton design="Transparent">Transparent ToggleButton</ui5-togglebutton>
<ui5-togglebutton design="Transparent" pressed>Transparent ToggleButton</ui5-togglebutton>
	

ToggleButton with Icon

Menu Add Back Accept Deny
<ui5-togglebutton icon="menu">Menu</ui5-togglebutton>
<ui5-togglebutton design="Emphasized" icon="add">Add</ui5-togglebutton>
<ui5-togglebutton design="Default" icon="nav-back">Back</ui5-togglebutton>
<ui5-togglebutton design="Positive" icon="accept">Accept</ui5-togglebutton>
<ui5-togglebutton design="Negative" icon="sys-cancel">Deny</ui5-togglebutton>
	

ToggleButton with Icon Only

<ui5-togglebutton icon="accept"></ui5-togglebutton>
<ui5-togglebutton icon="action-settings" pressed></ui5-togglebutton>
<ui5-togglebutton icon="add"></ui5-togglebutton>
<ui5-togglebutton icon="alert" pressed></ui5-togglebutton>
<ui5-togglebutton icon="away" design="Positive"></ui5-togglebutton>
<ui5-togglebutton icon="bookmark" design="Positive" pressed></ui5-togglebutton>
<ui5-togglebutton icon="cancel" design="Negative"></ui5-togglebutton>
<ui5-togglebutton icon="call" design="Negative" pressed></ui5-togglebutton>
<ui5-togglebutton icon="camera" design="Transparent"></ui5-togglebutton>
<ui5-togglebutton icon="cart" design="Transparent" pressed></ui5-togglebutton>
	

ToggleButton

Yes/No Yes/No Toggle Button Toggle Button pressed On/Off On/Off Menu Menu Transparent Transparent
<ui5-togglebutton>Yes/No</ui5-togglebutton>
<ui5-togglebutton pressed>Yes/No</ui5-togglebutton>
<ui5-togglebutton>Toggle Button</ui5-togglebutton>
<ui5-togglebutton pressed>Toggle Button pressed</ui5-togglebutton>
<ui5-togglebutton design="Positive">On/Off</ui5-togglebutton>
<ui5-togglebutton design="Positive" pressed>On/Off</ui5-togglebutton>
<ui5-togglebutton design="Negative">Menu</ui5-togglebutton>
<ui5-togglebutton design="Negative" pressed>Menu</ui5-togglebutton>
<ui5-togglebutton design="Transparent">Transparent</ui5-togglebutton>
<ui5-togglebutton design="Transparent" pressed>Transparent</ui5-togglebutton>
	

Overview

The ui5-togglebutton component is an enhanced ui5-button that can be toggled between pressed and normal states. Users can use the ui5-togglebutton as a switch to turn a setting on or off. It can also be used to represent an independent choice similar to a check box.

Clicking or tapping on a ui5-togglebutton changes its state to pressed. The button returns to its initial state when the user clicks or taps on it again. By applying additional custom CSS-styling classes, apps can give a different style to any ui5-togglebutton.

ES6 Module Import

import "@ui5/webcomponents/dist/ToggleButton";

Properties/Attributes

You can use both properties and attributes with the same effect. The name of each attribute is listed below the name of the property, if different.

Name
Type
Default Value
Description
pressed
boolean
false
Determines whether the ui5-togglebutton is displayed as pressed.
design
ButtonDesign
"Default"
Defines the ui5-button design.

Note: Available options are "Default", "Emphasized", "Positive", "Negative", and "Transparent".
disabled
boolean
false
Defines whether the ui5-button is disabled (default is set to false). A disabled ui5-button can't be pressed or focused, and it is not in the tab chain.
icon
string
""
Defines the icon to be displayed as graphical element within the ui5-button. The SAP-icons font provides numerous options.

Example:
ui5-button icon="palette"
See all the available icons in the Icon Explorer.
iconEnd
icon-end
boolean
false
Defines whether the icon should be displayed after the ui5-button text.
iconSize
icon-size
string
undefined
Defines the size of the icon inside the ui5-button.
since v1.0.0-rc.8
submits
boolean
false
When set to true, the ui5-button will automatically submit the nearest form element upon press.

Important: For the submits property to have effect, you must add the following import to your project: import "@ui5/webcomponents/dist/features/InputElementsFormSupport.js";

Slots

This Element provides slot(s). This means it can display its child nodes.
Unless targeting the default slot, use the slot attribute to define the destination slot for each child.
Text, along with HTML Elements with no slot attribute, goes the the default slot.

Slot
Type
Description
default
Node [0..n]
Defines the text of the ui5-button.

Note: –źlthough this slot accepts HTML Elements, it is strongly recommended that you only use text in order to preserve the intended design.

Events

This Web Component fires semantic events upon user interaction. You can bind to these events with the standard DOM APIs, such as addEventListener.

Name
Description
click
Fired when the ui5-button is activated either with a mouse/tap or by using the Enter or Space key.

Note: The event will not be fired if the disabled property is set to true.
Theme: Quartz Light Quartz Dark Quartz High Contrast Black Quartz High Contrast White Belize High Contrast Black High Contrast White
Content Density: Cozy Compact
Text Direction: LTR RTL
Apply Cancel