Skip to content
Logic2BUI

Search docs

Search components and documentation

New
Menu

Toggle

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

Installation

npx logic2b@latest add toggle

Usage

import { Toggle } from "@/components/ui/toggle"

<Toggle aria-label="Toggle italic">
  <ItalicIcon />
</Toggle>

API

Built on Radix Toggle.Root with cva variants.

Prop Type Default
variant default | outline default
size default | sm | lg default
pressed boolean — controlled state
defaultPressed boolean
onPressedChange (pressed: boolean) => void
disabled boolean false

Examples

Outline

With text

Sizes

Accessibility

  • Exposes aria-pressed so its on/off state is announced.
  • Toggle with Space or Enter when focused; reachable with Tab.
  • Icon-only toggles need an aria-label to provide an accessible name.