Skip to content

Toggle Group

Provides a shared state to a series of toggle buttons.

Anatomy

Toggle Group is composed together with Toggle. Import the components and place them together:

vue
<script setup lang="ts">
import { Toggle, ToggleGroup } from 'base-ui-vue'
</script>

<template>
  <ToggleGroup>
    <Toggle value="left" />
    <Toggle value="center" />
    <Toggle value="right" />
  </ToggleGroup>
</template>

Examples

Multiple

Add the multiple prop to allow pressing more than one toggle at a time.

API reference

PropTypeDefaultDescription
asstring | Component'div'The element or component to use for the root node.
valuestring[]undefinedThe pressed values of the toggle group. This is the controlled counterpart of default-value.
default-valuestring[]undefinedThe pressed values of the toggle group. This is the uncontrolled counterpart of value.
disabledbooleanfalseWhether the toggle group should ignore user interaction.
orientation'horizontal' | 'vertical''horizontal'The orientation of the toggle group.
loop-focusbooleantrueWhether keyboard navigation loops back to the first item after the last item.
multiplebooleanfalseWhether more than one toggle can be pressed at the same time.
classany | ((state: State) => any)undefinedCSS class applied to the element, or a function that returns a class based on the component's state.
styleStyleValue | ((state: State) => StyleValue)undefinedStyle applied to the element, or a function that returns a style object based on the component's state.
EmitsTypeDescription
value-change(value: string[], details: EventDetails) => voidEmitted when the pressed values change.
AttributeDescription
data-disabledPresent when the toggle group is disabled.
data-orientationIndicates the orientation of the toggle group.
data-multiplePresent when the toggle group allows multiple pressed toggles.