Skip to content
On this page

ToggleButton

A ToggleButton is a button that can be toggled on and off.

Guidelines

Using toggle buttons

Toggle buttons feature a normal and an “on” state. They generally contain a label and can also include an icon. For icon-only buttons, the label will be visually hidden while still available to screen reader users.

There are two types of toggle buttons: normal and quiet. There is no toggle button variant designed for progressive or destructive actions.

Use the ToggleButton component for options that require state persistence and are longer or more involved than a typical button click action. Avoid using ToggleButton if you need to trigger an immediate action or toggle something within the current user context; in this case use a Button instead.

Example of a normal and a quiet ToggleButton.

Specifications

Specification of ToggleButton.

ToggleButton may include the following elements:

  1. Icon (optional)
    Icons simplify user recognition and provide the ability to shorten button labels to a minimum.
  2. Label
    Button labels should be as short as possible, with text that clearly states what state is changed when toggling the button (eg. show/hide). Note that the label text should not change depending on the button’s toggled state.

Types

Depending on the style of the button, there are two types of toggle buttons:

  1. Normal toggle buttons. They are the default choice for simplified recognition.
  2. Quiet toggle buttons (frameless). Only use quiet toggle buttons for an easily recognizable action that does not detract focus from the content.

Type of Toggle Button based on its style: normal and quiet.

Depending on the button's content, it can have one of the following formats:

  1. Icon and text
  2. Text-only
  3. Icon-only

Type of toggle button based on its content: icon and text, text-only, and icon-only.

Interaction states

Buttons have the following visually separate states:

Interaction states of the normal toggle button for both toggled-off and toggled-on: default, hover, active, focus, and disabled.

Neutral buttons

Interaction states of the quiet toggle button for both toggled-off and toggled-on: default, hover, active, focus, and disabled.

Quiet buttons

  1. Toggled-off default
  2. Toggled-off hover
  3. Toggled-off active
  4. Toggled-off focus
  5. Toggled-off disabled
  6. Toggled-on default
  7. Toggled-on hover
  8. Toggled-on active
  9. Toggled-on focus
  10. Toggled-on disabled

Demos

Configurable

NameValue
Props
disabled
quiet
Slots
default
View
Reading direction

Default

Press the ToggleButton to see the value change. Open up the console to see emitted events.

ToggleButtons should always have a static label. This helps indicate to the user (including users of assistive technology) what it means for the button to be on or off. If you want a button with a label that changes when it is pressed, use the Button component instead.

Toggle button value: false

Icon only

When the ToggleButton includes only an icon and no text, add an aria-label to the ToggleButton to ensure the button is understandable to those using assistive technology.

Vue usage

The v-model value will be a boolean, it is true if the button is currently toggled ("on") and false otherwise ("off").

Props

Prop nameDescriptionTypeDefault
modelValueWhether the button should be set to "on" (true) or "off" (false).

Provided by v-model binding in the parent component.
booleanfalse
disabledWhether the disabled attribute should be added to the button, which prevents it from being clicked.booleanfalse
quietWhether the toggle button should be "quiet", which renders more minimally.booleanfalse

Events

Event namePropertiesDescription
update:modelValuemodelValue boolean - The new model valueEmitted when modelValue changes (i.e. when the state is toggled)

Slots

NameDescriptionBindings
defaultButton content