Motion
Five feels, ten roles and interruptible springs that respect Reduce Motion.
Motion describes a job, and a feel describes its character. Feels are smooth, snappy, springy, bouncy and none. The ten roles are press, toggle, select, morph, layout, overlay, drag, list, number and ambient.
import { MotionProvider } from '@/components/swipeui/lib/motion';
<MotionProvider feel="springy">
<App />
</MotionProvider>
<Button motion="snappy">Save</Button>A ThemeProvider inherits the preset's feel unless motion is explicit. Interactive controls and JavaScript tab bars accept a local motion override, including { feel, spring: { duration, dampingRatio }, pressScale }. Static leaves leave motion to their parents. Native tab transitions and native sheets remain platform-owned; attached sheet motion follows the app feel.
Authoring an animation
import { useMotion } from '@/components/swipeui/lib/motion';
const motion = useMotion('select');
position.set(withSpring(target, motion.spring)); // UI-thread springUse spring for stateful movement, timing for timed numbers, fade for opacity and exit for shorter exits. CSS samples share the duration-based spring equations, but CSS transitions cannot carry finger release velocity. Follow a drag directly, then use the spring with its release velocity. Toggle/select springs clamp their end state even in bouncy. Selection haptics follow accepted detents; primary impacts happen on activation.
Reduce Motion
System Reduce Motion always wins. none removes travel and allows short opacity feedback. A nested provider can force reduceMotion="always" for previews; it cannot bypass system preferences. Reanimated's system snapshot is read at startup, so restart the app when comparing device settings. Native APIs also receive system reduction settings.
Development lab
The showcase /motion-lab compares all roles across all feels. Development-only timeScale={2} and {4} preview 0.5× and 0.25×. Ambient examples are manually triggered, with no background loops. Number examples run on the UI thread. On-device feel tuning remains pending.
Provider API
| Prop | Type | Default | Description |
|---|---|---|---|
children | | — | |
feel? | | | Character inherited by animated items. |
reduceMotion? | | | System preferences cannot be bypassed. |
timeScale? | | | Multiplier for durations in development only; 4 means quarter speed. |
Accessibility
- System Reduce Motion and forced previews remove travel; no provider option bypasses the system preference.
Motion
- Uses the
press,toggle,select,morph,layout,overlay,drag,list,numberandambientmotion roles, so it follows your app's feel. Passmotionto tune this one instance. - Uses shared role springs and inherited or local motion settings; system Reduce Motion removes travel. Native device tuning remains pending.
- Ambient timing now has feel-owned loop periods; consumers do not multiply component-local durations.
Performance
- Native animations run on the UI thread; custom CSS sample curves are computed only when hook inputs change.
Notes for AI
- Read spring for withSpring, timing for withTiming and css for CSS transitions. CSS transitions cannot preserve release velocity.
Compatibility
| Runs on | Supported |
|---|---|
| Expo SDK 57 | Yes |
| Expo SDK 58 | Yes |
| React Native CLI (with Expo modules) | Yes |
| Expo Go | Yes |
| iOS | Yes |
| Android | Yes |
This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.