Skip to content

Toggle

A two-state button that can be on or off.

Anatomy

Import the component:

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

<template>
  <Toggle />
</template>

API reference

PropTypeDefaultDescription
asstring | Component'button'The element or component to use for the root node.
pressedbooleanundefinedWhether the toggle button is currently pressed. This is the controlled counterpart of default-pressed.
default-pressedbooleanfalseWhether the toggle button is initially pressed. This is the uncontrolled counterpart of pressed.
disabledbooleanfalseWhether the component should ignore user interaction.
valuestringundefinedA unique string that identifies the toggle when used inside a toggle group.
native-buttonbooleantrueWhether the component renders a native <button> element.
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
pressed-change(pressed: boolean, details: EventDetails) => voidEmitted when the pressed state changes.
AttributeDescription
data-pressedPresent when the toggle button is pressed.
data-disabledPresent when the toggle button is disabled.