Tally UI
Primitives

Toggle

A button that toggles between pressed and unpressed states.

Import

import { Toggle } from '@tallyui/primitives';

Usage

<Toggle.Root pressed={bold} onPressedChange={setBold}>
  <BoldIcon />
</Toggle.Root>

Components

Toggle.Root

A pressable button that maintains a pressed/unpressed state.

PropTypeDefaultDescription
pressedbooleanControlled pressed state
defaultPressedbooleanfalseInitial state (uncontrolled)
onPressedChange(pressed: boolean) => voidCalled when pressed state changes
disabledbooleanfalsePrevents interaction
asChildbooleanfalseMerge props onto child instead of rendering

Plus all React Native PressableProps.

Accessibility

  • Role: button
  • ARIA: aria-pressed, aria-disabled
  • Toggles on press

On this page