Skip to content

ToggleButton ​

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

NameValue
Props
disabled
quiet
size
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.

Button sizes ​

Buttons can be small, medium (default) or large size.

  1. Small
    Use the small size only when space is tight: for example, inline with text or in compact layouts.
  • Use lowercase letters to make the button fit better with surrounding text.
  • Avoid using small buttons on touchable screens.
  1. Medium
    Use medium as the standard button size.
  2. Large
    Use the large size to support accessibility on touchscreens by increasing the touch area.

By default, the width of a Button with text is determined by the width of the text until reaching a max-width. However, on mobile, Buttons should span the full-width of the container, except for icon-only Buttons, which will maintain their fixed square proportions.

Button size examples for all supported size values.
SizeMin-sizeText buttonIcon-only button
Small24px
Medium32px
Large44px

Developer notes

Set min-width manually on Buttons with extremely short labels. Buttons with text labels of only 1-2 characters in length may fall below size of the target area described above. In these cases, set a minimum width of @min-size-interactive-pointer in your own CSS.

With icon ​

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

Icon-only ​

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 nameDescriptionTypeValuesDefault
modelValueWhether the ToggleButton should be set to "on" (true) or "off" (false).

Provided by v-model binding in the parent component.
boolean-false
disabledWhether the disabled attribute should be added to the ToggleButton, which prevents it from being clicked.boolean-false
quietWhether the ToggleButton should be "quiet", which renders more minimally.boolean-false
sizeButton size.

Medium: Default for most cases. Large: Use rarely, mainly for icon-only buttons on touchscreens. Small: Use in tight spaces or inline with text. Avoid on touchscreens - prefer medium for better accessibility.
ButtonSize'small', 'medium', 'large''medium'

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.