Segmented Switcher with Rolling Digits
Switching between Drive, Transit, Walk and Bike moves a white indicator on a front-led spring as only changed digits of the minutes and arrival time roll. The route bar stretches between solid, dotted and transfer segments, and each icon animates its mode.
export function Example() {
const progress = useSharedValue(0);
…
Agent prompt
Add the Now In Code component "segmented-switcher-with-rolling-digits" to this project. The full source is attached at the end of this prompt. Put the files under components/segmented-switcher-with-rolling-digits/, install the listed dependencies with `npx expo install`, and render it on a route I can open. Keep the timing and easing values documented in the source comments. Replace the sample copy and artwork with content from my app, or leave placeholders and list what I still need to supply. === Source files are attached here for paid plans ===
Details
- Platforms
- iOS, Android, Web
- Requires
- Expo SDK 54+
- Access
- Pro
- Updated
- 11 Nov 2026
- License
- Unlimited commercial projects
- Original design
- @dev_ya on X
Are you the designer? Ask us to change or remove this.
Add pieces from the terminal or let your agent fetch them. Until then, Copy prompt does the same job. Docs
What it does
A white commute card with a four-way segmented control for Drive, Transit, Walk and Bike. Choosing a mode slides a white indicator to it, stretching slightly as it travels, and each icon acts out its mode. The travel time rolls to its new digits, the arrival time and the route caption change in place, and the route line redraws: solid blue for driving and biking, a grey dotted line with a blue stretch for transit, and a dotted blue line for walking. Biking adds a Fastest badge. Pressing the indicator shrinks it, and dragging it follows the finger, then snaps to the nearest mode on release, which is when the data switches.
How it's built
A shared JavaScript timeline module holds the mode data and the animation state, and the React Native component draws with react-native-svg while a requestAnimationFrame loop advances it. The indicator uses two spring-driven edges, with the leading edge ahead of the trailing one, which produces the stretch. Dragging is handled with PanResponder. Digits sit in fixed tabular slots so the unit label never moves.
Good for
- A route or travel-mode picker in a maps or rideshare app
- A plan or pricing switcher where the figures should update in place
- Any segmented control whose labels should react as the indicator passes under them
Dependencies
react-native-svgreact-native