SwipeUI

Toggle group

Connected state choices for editing tools, layouts and filters.

npx @swipeui/cli add toggle-group
Variant
Preset
Material
Scheme
Feel
Real free component with a browser animation bridge. Native motion, haptics and materials need a device.

When to use it

  • Representing persistent formatting, layout or filter state.

When not to use it

  • Triggering an action; use ButtonGroup.

Installation

Run this from your app's root. If SwipeUI isn't set up yet, run npx @swipeui/cli init first; it sets up Uniwind, the theme tokens and the cn helper.

npx @swipeui/cli add toggle-group
  • Adds components/swipeui/ui/toggle-group.tsx, components/swipeui/ui/use-toggle-group.ts and 15 shared helpers.
  • Installs react-native-reanimated, react-native-gesture-handler, uniwind, clsx, tailwind-merge, react-native-worklets, expo-haptics, class-variance-authority, react-native-svg, react-native-safe-area-context. In Expo apps it uses npx expo install so versions match your SDK.

Usage

import { ToggleGroup } from '@/components/swipeui/ui/toggle-group';
<ToggleGroup type="multiple" options={[{value:'bold',label:'Bold'},{value:'italic',label:'Italic'}]} />;

Examples

Use single mode for a layout and multiple mode for formatting.

API reference

PropTypeDefaultDescription
optionsreadonly ToggleGroupOption<T>[]—

Choices; icon-only items still require a label.

type?"multiple" | "single"'single'

Selection mode.

value?T | readonly T[]—

Controlled choice or choices.

defaultValue?T | readonly T[]—

Initial choice or choices.

onValueChange?((value: T | readonly T[] | undefined) => void)—

Reports the accepted state.

allowEmpty?booleanfalse

Allow clearing a single choice.

size?"md" | "sm"'md'

Visual size; both retain 44pt targets.

wrap?booleanfalse

Wrap rather than scroll.

tooltip?booleantrue

Show icon-only labels on hold.

paintSelect?booleantrue

Hold and paint choices.

disabled?booleanfalse

Disable every choice.

accessibilityLabel?string—

Name of the group.

haptics?boolean | SelectionHapticstrue

Selection feedback.

motion?MotionOverride—

App motion override.

className?string—

Root classes.

style?StyleProp<ViewStyle>—

Root style.

testID?string—

Root identifier.

Toggle group settings

PropDoesDefault
typeSingle or multiple choicessingle
allowEmptyClear a single choicefalse
sizeSmall or medium surfaces with 44pt targetsmd
wrapWrap instead of scrollfalse
tooltipShow icon labels on holdtrue
paintSelectHold then paint choicestrue
hapticsSelection feedbacktrue
motionShared app motionApp feel

Composition and behavior

ButtonGroup performs actions; ToggleGroup represents state. Every icon-only item needs a label. Disabled reasons are exposed as accessibility hints. The single highlight glides; adjacent multiple choices join their inner corners.

Behavior and gestures

  • Tap to choose or hold and paint across choices.

Accessibility

  • Single choices use radios; multiple choices use selected toggle buttons.

Motion

  • Uses the select, toggle and press motion roles, so it follows your app's feel. Pass motion to tune this one instance.
  • The dot fills with the toggle role; the cards variant moves a selection ring with the select role.
  • Reduce Motion changes selection instantly.

Performance

  • Plain row frames are retained for hit-testing; animation styles live in the highlight leaf.

Notes for AI

  • Give options unique values; null means nothing selected.

Compatibility

Runs onSupported
Expo SDK 57Yes
Expo SDK 58Yes
React Native CLI (with Expo modules)Yes
Expo GoYes
iOSYes
AndroidYes

This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.

Related items