Skip to content

Toggle

Turn a button on or off.

Demos

Size
Variant
State

Usage

vue
<script setup lang="ts">
import { Accordion } from '~/components/ui/accordion'

const items = [
  { value: 'source', label: 'Do I own the source?', content: 'Yes. Copy and adapt the files.' },
]
</script>

<template>
  <Accordion :items="items" />
</template>

Installation

Complete the shared installation. Copy Toggle.vue and index.ts into app/components/ui/toggle/.

API

Variants and defaults

PropValuesDefault
sizexs, sm, md, lg, xlsm
variantsoft, outlinesoft

Props

PropTypeDefaultDescription
modelValuebooleanfalseWhether the toggle is pressed.
disabledbooleanfalseDisables the toggle.
valuestringโ€”Value used when the toggle is part of a group.
ariaLabelstringโ€”Accessible label for icon-only toggles.
asstring"button"Root element tag.
uiToggleUiโ€”CSS class overrides.

Slots

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

Events

EventPayloadDescription
pressed-change[pressed: boolean, details]Fired when pressed state changes.

Keyboard

KeyBehavior
Enter / SpaceToggles pressed state. Works for native button and custom as roots.
Tab / Shift + TabUses native focus order and skips disabled toggle.