Toggle
A toggle is used to quickly switch between two possible states. They are commonly used for “on/off” switches.
Overview
Toggle is a control that is used to quickly switch between two possible states. Toggles are only used for these binary actions that occur immediately after the user “flips the switch”. They are commonly used for “on/off” switches.
Live demo
<Togglearia-label="toggle button"defaultToggledid="toggle-1"labelText="Label text"/>
Variants
Variant | Purpose |
---|---|
Default toggle | Use the default toggle when you need to specify a label text in addition to the toggle action text. Default toggles appear in forms or within full pages of information. |
Small toggle | Use the small toggle when you do not need to specify label or action text. Small toggles are more compact in size and are used inline with other components. |
![Default and small toggle variants Default and small toggle variants](/static/88c8401f7df4cae8ab13c48f3fa9b637/3cbba/toggle-usage-variants.png)
Default and small toggle variants
Content
Label text
Label text must accompany a toggle to further clarify the action that the toggle performs.
Action text
Use text to describe the binary action of toggle so that the action is clear. Action text must be three words or less and is displayed on the side of a toggle.
Language
Use adjectives rather than verbs to describe actions and the state of the object affected.
Behaviors
States
Toggles have six states: on, off, focus, disabled, skeleton, and read-only.
![Default and small toggle variants Default and small toggle variants](/static/e33dec6f896ee88d2f55d3ff513d4202/3cbba/toggle-usage-states.png)
Example of toggle states
Default toggle
Default toggles are larger in size than small toggles. They are commonly used in forms and can appear within full pages of information that are not restricted in space. Default toggles are required to display visible label and action text.
![Example of a default toggle in context Example of a default toggle in context](/static/e1bf0c21701504fdc0fe75defa51994f/3cbba/toggle-usage-default.png)
Example of a default toggle in context
Small toggle
Small toggles are often used in condensed spaces and appear inline with other components or content, for example, inside data table rows. Unlike the default toggle, the small toggle is more compact in size and displays a checkmark tick in the on state to ensure the toggle is still accessible without requiring visible label or action text.
![Example of a small toggle in context Example of a small toggle in context](/static/b40df140e7ddb8221c596d9ba8b99719/3cbba/toggle-usage-small.png)
Example of a small toggle in context
Feedback
Help us improve this component by providing feedback, asking questions, and leaving any other comments on GitHub.