Skip to content

ToggleButton

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

NameValue
Props
disabled
quiet
Slots
default
View
Reading direction

Overview

When to use ToggleButton

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; in this case use a Button instead.

There are two types of ToggleButtons: normal and quiet. Only use quiet ToggleButton for an easily recognizable action that does not detract focus from the content. There is no ToggleButton variant designed for progressive or destructive actions.

About ToggleButton

ToggleButton includes the following elements.

Label

Labels should be as short as possible, with text that clearly states what state is changed when toggling the ToggleButton (eg. show/hide).

ToggleButton label should ideally be fewer than 38 characters in English, as translations average 42 characters. Logographic and Arabic-script languages are generally shorter, while Romance, some Germanic, Slavic, Austronesian, and others like Greek and Finnish tend to be longer, averaging 45–53 characters.

  • Use the same text and icon in both off and on states.

  • Use descriptive, accessible verbs to encourage action. Concise & Accessible

  • Write in sentence case, capitalising only the first word. Consistent

  • Avoid using similar words for different ToggleButtons. Clear

  • Avoid verbs that imply visual or sensory abilities such as "see", or are idiomatic or vague. Accessible & Translatable

Icon (optional)

Icons simplify user recognition and provide the ability to shorten labels to a minimum. For icon-only ToggleButtons, the label will be visually hidden while still available to screen reader users.

  • Ensure that icons used in ToggleButtons are relevant and easily recognizable.
  • Avoid using icons that are difficult to recognize or do not clearly convey their purpose.

Examples

Basic usage

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

Press the ToggleButton to check the value change.

Developer notes

Open up the console to check emitted events.

With icon

Use an icon with the ToggleButton label when you need to convey meaning through both textual and visual elements.

Icon-only button

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

Technical implementation

Vue usage

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

Props

Prop nameDescriptionTypeDefault
modelValueWhether the ToggleButton 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 ToggleButton, which prevents it from being clicked.booleanfalse
quietWhether the ToggleButton 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
defaultToggleButton content

Keyboard navigation

KeyFunction
TabIt moves the focus to the next interactive element.
Shift + TabIt moves the focus to the previous interactive element.
Enter / SpaceIf the focus is placed on the button, it toggles the ToggleButton on and off.