Skip to content

Toggle

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

Toggle renders one button with pressed and unpressed states. Use Switch when the control needs a visible field label.

Anatomy

  • #default: Button content. Receives { pressed, state } scoped props.

Usage

The quick brown fox jumps over the lazy dog.

Examples

Toolbar group

Use Toggle inside toolbars for independent on/off controls.

vue
@layer akaza-reset;
@import "tailwindcss";
@import "akaza-ui/dist/akaza-ui.css";

Using the state prop

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

vue
<template>
  <Avatar
    src="/avatar.jpg"
    alt="Jane Doe"
    text="JD"
    :delay-ms="300"
  />
</template>

API Reference

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".

Emits

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

UI Options

KeyDescription
rootThe button element.

Styling Hooks

UI keyCSS classData attrs
rootakaza-toggledata-akaza-state, data-akaza-disabled

Keyboard

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