Skip to content
Native Animation
Spring Toggle animation preview

Spring Toggle

A draggable, light-reactive switch whose thumb stretches, glows, and settles with a spring.

Free
Get it free with your email

No password and no card: we email you a sign-in link, then the full source is yours.

Add to your project

Copy the component and its assets into your app with the Native Animation CLI, or paste the agent prompt into Claude Code, Codex or Cursor once the MCP server is connected.

npx nativeanimation add spring-toggle

About this animation

A draggable, light-reactive switch whose thumb stretches, glows, and settles with a spring.

How it works

  1. One shared progress value drives thumb position, track color, and icon blending.
  2. A pan gesture maps horizontal travel to progress and uses release velocity to choose the final state.
  3. Thumb width peaks halfway through the transition before returning to its resting shape.
  4. Controlled and uncontrolled state share the same request path, including the imperative API.
  5. A short active-state glow and light sweep provide the success beat without delaying input.

Install

npx expo install expo-linear-gradient react-native-gesture-handler react-native-reanimated react-native-worklets

Usage

<SpringToggle defaultValue onValueChange={setEnabled} />

<SpringToggle size="lg" thumbIcon="sun-moon" onColor="#625BF6" springDamping={20} />

<SpringToggle colorScheme="dark" glowColor="#1FC28B" onColor="#1FC28B" />

Props

PropTypeDefaultDescription
valueboolean—Controlled value.
defaultValuebooleanfalseInitial uncontrolled value.
onValueChange(value: boolean) => void—Receives requested values.
size'sm' | 'md' | 'lg''md'Control size.
onColorstring'#625BF6'On-track color.
offColorstring'#D7D7DE'Off-track color.
colorScheme'light' | 'dark' | 'auto''auto'Thumb and material appearance.
glowColorstringonColorActive thumb glow color.
thumbIcon'none' | 'sun-moon' | 'check''none'Thumb artwork.
springDampingnumber18Spring damping.
springStiffnessnumber280Spring stiffness.
accessibilityLabelstring'Toggle setting'Screen-reader label.
styleStyleProp<ViewStyle>—Outer style.
testIDstring—Test identifier.

The ref exposes toggle() and setValue(value).

Compatibility

  • Expo SDK 57, React Native 0.86, Reanimated 4.5
  • iOS and Android supported but not device-verified; web verified by the project gate
  • Works in Expo Go

Accessibility

The control exposes the switch role and checked state. Reduced Motion removes travel and stretch while preserving immediate state changes.

Source code

Free with an account

Sign in with your email to read the full source here, or install it in one command with the CLI.

Get it free