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.
Prop | Type | Default |
---|---|---|
defaultPressed | boolean | |
pressed | boolean | |
disabled | boolean | |
as | string | Component | button |
asChild | boolean | false |
Emit | Type |
---|---|
@update:pressed | (value: string) => void |
Data Attribute | Value |
---|---|
[data-state] | "on" | "off" |
[data-disabled] | Present when disabled |
Accessibility
Keyboard Interactions
Key | Description |
---|---|
Space | Activates/deactivates the toggle. |
Enter | Activates/deactivates the toggle. |