Components

Toggle

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

A single button that toggles between pressed and unpressed states. Use it for toolbar actions, view toggles, or any binary UI control that doesn't need a label (see Switch for a labeled toggle field).

Anatomy

  • #default — the button content, receives { pressed, state } scoped props

Usage

The quick brown fox jumps over the lazy dog.

Examples

Toolbar group

<template>
  <div role="toolbar" aria-label="Text formatting">
    <Toggle v-model="bold" aria-label="Bold">
      <template #default="{ pressed }">
        <span :data-active="pressed">B</span>
      </template>
    </Toggle>

    <Toggle v-model="italic" aria-label="Italic">
      <template #default="{ pressed }">
        <span :data-active="pressed">I</span>
      </template>
    </Toggle>
  </div>
</template>

Using the state prop

state is "on" or "off" — useful for data-attribute-driven styling.

<template>
  <Toggle v-model="active" aria-label="Mute">
    <template #default="{ state }">
      <span :data-state="state">🔇</span>
    </template>
  </Toggle>
</template>

API Reference

Props

PropTypeDefaultDescription
modelValuebooleanfalseWhether the toggle is pressed.
disabledbooleanfalseDisables the toggle.
valuestringValue used when the toggle is part of a group.
ariaLabelstringAccessible label for icon-only toggles.
asstring"button"Root element tag.
uiToggleUiCSS class overrides.

Slots

SlotScoped propsDescription
default{ pressed, state }Button content. state is "on" or "off".

UI Options

KeyDescription
rootThe button element.