Skip to main content
The Toggle component provides a button that can be pressed/unpressed to toggle between two states.

Installation

Usage

Props

boolean
Controlled pressed state.
boolean
Default pressed state.
function
Callback when state changes: (pressed: boolean) => void
string
default:"default"
Visual variant.Options: default, outline
string
default:"md"
Size of the toggle.Options: sm, md, lg, icon
boolean
Disable the toggle.

Variants

  • default: Transparent border
  • outline: Visible border

Sizes

  • sm: h-8, text-sm
  • md: h-9 (default)
  • lg: h-10
  • icon: size-9 (square)

Examples

Basic Toggle

With Icons

Variants

Sizes

Controlled

Toggle Group (Text Formatting)

Accessibility

  • Built on @base-ui/react for ARIA support
  • Keyboard accessible
  • Proper aria-pressed state
  • Focus visible ring
  • Disabled state prevents interaction