Skip to content

Toggle ​

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

Features ​

  • Full keyboard navigation.
  • Can be controlled or uncontrolled.

Installation ​

Install the component from your command line.

bash
npm install radix-vue

Anatomy ​

Import the component.

vue
<script setup>
import { Toggle } from 'radix-vue'
</script>

<template>
  <Toggle />
</template>

API Reference ​

Root ​

The toggle.

PropTypeDefault
defaultPressed
boolean
pressed
boolean
disabled
boolean
as
string | Component
button
asChild
boolean
false
EmitType
@update:pressed
(value: string) => void
Data AttributeValue
[data-state]"on" | "off"
[data-disabled]Present when disabled

Accessibility ​

Keyboard Interactions ​

KeyDescription
Space
Activates/deactivates the toggle.
Enter
Activates/deactivates the toggle.