structyl

Toggle API

View component

The full prop reference for the Toggle component. A two-state button that can be on or off.

Import

tsx
import { Toggle } from '@structyl/styled';

Props

Toggle

A button component that toggles between pressed and unpressed states. Combines a headless primitive with styled variants, sizes, and colors.

PropTypeDefault
pressed#boolean

Controlled pressed state (true when active/on, false when inactive/off)

defaultPressed#boolean

Uncontrolled initial pressed state

false
onPressedChange#(pressed: boolean) => void

Callback fired when the pressed state changes

disabled#boolean

Disables the toggle, preventing interaction and reducing opacity

asChild#boolean

If true, renders as its child element instead of a button

variant#'default' | 'outline'

Visual variant style (default has transparent background; outline has border)

'default'
color#'default' | 'primary' | 'secondary' | 'error' | 'warning' | 'info' | 'success'

Color scheme applied when pressed/active (data-state=on)

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

Button size (sm: h-9 px-2.5; default: h-10 px-3; lg: h-11 px-5)

'default'
className#string

Tailwind CSS classes merged with variant styles

children#React.ReactNode

Button content (text, icons, or elements)

Source code

If you didn't find what you need here, read the component implementation .

structyl — Accessible React Component Library