About this animation
A React Native animated counter should make value changes legible instead of moving every digit at once. This thermostat stepper splits the formatted number into right-aligned character windows and rolls only the characters that change, even when a new update interrupts the previous one. Use it for temperature, quantity, score, duration, or other bounded numeric settings that benefit from tactile plus and minus controls. Reanimated shared values coordinate each roller, the warm-to-cool surface tint, press feedback, and motion echoes without per-frame React state. Expo Linear Gradient adds material depth. The component supports controlled and uncontrolled values, custom limits and steps, press-and-hold repeat, colors, fonts, units, callbacks, and imperative increment, decrement, and setValue methods.
When to use it
- Adjust a thermostat or climate setting.
- Step through bounded quantities or scores.
- Show an odometer-style changing value.
- Add press-and-hold repeat to numeric controls.
Related guides
Choose a value selector by task
A category, a measurement, and a numeric adjustment need different controls. Choose the value model before the visual material.
- Choose from named options · Wheel Picker
- Measured label centers handle uneven text widths; momentum settles on one discrete option.
- Enter a physical measurement · Measure Ruler Picker
- A ruler with snapping and unit switching makes neighboring measurements visible around the selected value.
- Adjust a temperature target · Thermostat Dial
- A circular dial connects degree selection to an arc and rolling temperature in a climate-control layout.
- Adjust continuous levels · Gooey Merge Slider
- A liquid thumb and track visualize channel levels; choose it for a bounded slider rather than named options or physical measurements.
- Make precise one-step adjustments · Rolling Temperature Stepper (this piece)
- Increase and decrease controls change a bounded value, with rolling digits instead of a drag surface.
- Set a cart quantity · Quantity Stepper
- An Add action expands into a compact quantity control and returns to its initial state at zero.
- Choose a rating · Drag Star Rating
- A bounded star scale communicates a qualitative score rather than a physical unit or arbitrary number.
A thermostat stepper with rolling digits and temperature-linked color washes, with configurable bounds, warm color, and font.
How it works
onLayoutsupplies the card dimensions, and every radius, control zone, type size, and animation distance is derived from those measurements.- The formatted number is split into right-aligned character windows. Each window owns one shared progress value and keeps an outgoing and incoming character, so unchanged digits remain completely still.
- When a second update interrupts a roll, the current incoming character becomes the next outgoing character. Its new progress starts below zero when necessary, preserving its on-screen position before it continues toward the next value.
- Two offset ghost copies follow each moving character. Their opacity and vertical stretch peak halfway through the roll to suggest motion blur without a native blur effect.
- A shared value from −1 to 1 drives the cool-to-warm tint, while its absolute value controls tint strength. Press and limit feedback remain independent from the displayed value.
Install
npx expo install expo-linear-gradient react-native-reanimated react-native-workletsUsage
import RollingTemperatureStepper from './RollingTemperatureStepper';
export function ThermostatCard() {
return <RollingTemperatureStepper style={{ width: 143, height: 218 }} />;
}Use a controlled value, visual knobs, and the imperative API when integrating it into a larger climate screen:
import { useRef, useState } from 'react';
import RollingTemperatureStepper, {
type RollingTemperatureStepperRef,
} from './RollingTemperatureStepper';
export function ThermostatCard() {
const [temperature, setTemperature] = useState(70);
const stepperRef = useRef<RollingTemperatureStepperRef>(null);
return (
<RollingTemperatureStepper
ref={stepperRef}
value={temperature}
min={55}
max={82}
neutral={68}
tintRange={8}
warmColor="#E9A7AF"
coolColor="#9FC3EE"
fontFamily="YourSansFont"
onChange={setTemperature}
style={{ width: 160, height: 244 }}
/>
);
}The forwarded ref exposes increment(), decrement(), and setValue(value). In controlled mode these methods request a value through onChange; the visible number follows the value prop.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
value | number | undefined | Controlled value. Omit to let the component keep its own state. |
defaultValue | number | DEFAULT_VALUE | Initial value when uncontrolled. |
min | number | DEFAULT_MIN | Minimum temperature. |
max | number | DEFAULT_MAX | Maximum temperature. |
step | number | DEFAULT_STEP | Amount changed by each press. |
neutral | number | DEFAULT_NEUTRAL | Temperature with no tint. |
tintRange | number | DEFAULT_TINT_RANGE | Degrees above/below neutral at which the tint is full. |
unit | string | '°' | Unit displayed after the number. |
warmColor | string | DEFAULT_WARM | Warm tint color. |
coolColor | string | DEFAULT_COOL | Cool tint color. |
cardColor | string | DEFAULT_CARD | Card background color. |
textColor | string | DEFAULT_TEXT | Number and control color. |
repeatOnHold | boolean | true | Repeat while holding a half. |
fontFamily | string | undefined | Font family for the number. |
onChange | (value: number) => void | undefined | Called when the user or imperative API requests a new value. |
incrementAccessibilityLabel | string | 'Increase temperature' | Label for the upper control. |
decrementAccessibilityLabel | string | 'Decrease temperature' | Label for the lower control. |
style | StyleProp<ViewStyle> | undefined | Optional style for the outer card. |
testID | string | undefined | Test identifier applied to the outer card. |
duration | number | 450 | Temperature tint transition duration in milliseconds. Spring physics and reduced-motion timing are unchanged. |
Compatibility
- Expo SDK 58
- React Native 0.88
- Reanimated 4.7
- iOS: supported
- Android: supported
- Web: supported
- Works in Expo Go because its native dependencies are bundled with the SDK
Accessibility
Both halves are labeled buttons, with overridable labels for product-specific wording. Reduced Motion replaces digit travel with a 120 ms crossfade, removes the ghost trail and card scale, and keeps value, tint, press feedback, and limit behavior functional.
FAQ
- Does the animated counter work in Expo Go and on web?
- Yes. Its Expo SDK 58 and Expo SDK 57 dependencies are available in Expo Go, and web is verified by the project gate. Each published piece is reviewed on physical iPhone and Android devices with Expo Go before release.
- Can it display values other than temperature?
- Yes. Configure value, min, max, step, neutral, unit, colors, and callbacks. The temperature labels can also be replaced through the accessibility label props.
- How does the counter behave with Reduce Motion?
- Digit travel becomes a short crossfade, and the ghost trail and card scale are removed. The value, tint, controls, and limit behavior remain fully functional.




