ToggleButton

ToggleButton is used to select a boolean value using a button.

Migrating to PrimeVue: What Changed and Why
A hands-on guide to the new compound component API, headless hooks, and Tailwind-first theming in PrimeVue v11.
May 12
PREVIEW

Two-way binding to a boolean property is defined using the standard v-model directive.

basic-demo

Use the icon template to customize what the component displays based on its internal state.

customized-demo

ToggleButton provides small and large sizes as alternatives to the base.

sizes-demo

The invalid state is applied using the invalid property to indicate failed validation, which can be integrated with form validation.

invalid-demo

When disabled is present, the element cannot be edited and focused.

disabled-demo

The fluid prop makes the component take up the full width of its container when set to true.

fluid-demo

ToggleButton integrates seamlessly with the PrimeVue Forms library.

forms-demo

Screen Reader

ToggleButton component uses an element with button role and updates aria-pressed state for screen readers. Value to describe the component can be defined with aria-labelledby or aria-label props, it is highly suggested to use either of these props as the component changes the label displayed which will result in screen readers to read different labels when the component receives focus. To prevent this, always provide an aria label that does not change related to state.

Keyboard Support

KeyFunction
tabMoves focus to the button.
spaceToggles the checked state.
Theme Designer