structyl

Toggle

stable

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

Basic usage

Examples

Outline variant

The outline variant pairs well with text editor toolbars.

Toggle variants and sizes

Use Toggle for formatting controls, filters and icon buttons.

Semantic colors

Color prop sets the pressed-state background and text for semantic toggles.

Features

  • Controlled or uncontrolled.
  • Two variants, three sizes.

Installation

bash
pnpm dlx structyl add toggle

API Reference

Toggle

A two-state pressable button.

PropTypeDefault
pressedboolean

Controlled pressed state.

defaultPressedboolean

Initial pressed state.

onPressedChange(pressed: boolean) => void

Called when toggled.

variant'default' | 'outline'

Visual style.

'default'
size'default' | 'sm' | 'lg'

Control size.

'default'
disabledboolean

Disable the toggle.

Toggle | structyl