Three pickers for React Native that share one gesture engine: a ruler-style wheel with momentum and snapping, an analog clock you set by dragging its hands or scrubbing a time strip, and a circular duration dial. Drawn with Skia, animated with Reanimated on the UI thread, with haptic ticks, controlled or uncontrolled values, and screen-reader adjustable actions.
Demo recorded on the iOS Simulator from the example app, shown at 2x speed. Full video: docs/demo.mp4.
npm install @asaddevworld/pickers @shopify/react-native-skia react-native-reanimated react-native-worklets react-native-gesture-handlerWith Expo:
npx expo install @asaddevworld/pickers @shopify/react-native-skia react-native-reanimated react-native-worklets react-native-gesture-handlerRequires React Native 0.76 or newer, Skia 2, Reanimated 4, and Gesture Handler 3, with GestureHandlerRootView at the root of the app.
import { WheelPicker, ClockPicker, DurationDial } from '@asaddevworld/pickers';
<WheelPicker value={weight} min={30} max={200} step={1} majorEvery={10} unit="kg" onChangeEnd={setWeight} />
<ClockPicker value={{ hours: 9, minutes: 30 }} minuteStep={5} onChangeEnd={setTime} />
<DurationDial value={hours} min={1} max={12} unit="h" onChangeEnd={setHours} />Hook up haptics with any library:
import * as Haptics from 'expo-haptics';
const haptics = (event: 'tick' | 'settle') =>
event === 'tick' ? Haptics.selectionAsync() : Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);
<WheelPicker haptics={haptics} ... />| prop | type | description |
|---|---|---|
value |
number (or ClockTime) |
Controlled value. |
defaultValue |
same | Starting value when uncontrolled. |
onChange |
(value) => void |
Fires on every step crossed while dragging. |
onChangeEnd |
(value) => void |
Fires once the picker settles. |
haptics |
(event: 'tick' | 'settle') => void |
Called per step and on settle. |
theme |
{ tint, track, text, background } |
Colours. Defaults suit a dark background. |
accessibilityLabel |
string |
Label for the adjustable control. |
| prop | default | description |
|---|---|---|
min, max, step |
0, 100, 1 |
Range and granularity. |
majorEvery |
10 |
Every n-th tick is taller and labelled. |
unit |
Appended to the live value. | |
expanded |
false |
Wider tick spacing, animated when toggled. |
formatLabel |
Worklet that formats the value and the major tick labels. | |
height |
96 |
Ruler height. |
hideValue |
false |
Hide the big live value above the ruler. |
| prop | default | description |
|---|---|---|
value / defaultValue |
{ hours: 9, minutes: 0 } |
{ hours, minutes } in 24-hour terms. |
size |
240 |
Diameter of the face. |
use24Hour |
false |
Strip and label show 24-hour times. |
minuteStep |
5 |
Minute increments. |
hideStrip |
false |
Hide the scrubbable time strip under the face. |
Drag near the minute hand to set minutes (the hour hand rolls along); drag near the hour hand to set hours. formatClock, toMinutes and toTime are exported helpers.
| prop | default | description |
|---|---|---|
min, max, step |
1, 12, 1 |
Range and granularity. |
size |
260 |
Diameter. |
unit |
Appended to the centre value. | |
thickness |
14 |
Ring thickness. |
formatLabel |
Worklet that formats the centre value and tick labels. |
- The wheel follows the finger 1:1, rubber-bands at the ends, and on release projects the velocity to pick the tick it settles on.
- The dial does not wrap: dragging past the top from the last value, or below the first, holds at the end.
- Every picker has the adjustable accessibility role with increment and decrement actions.
- Reduced motion shortens the settle animations.
yarn
yarn example iosOne screen with the three pickers, their settled values, and toggles for expanded ticks and 24-hour time.
Inspired by the wheel picker, clock time picker and duration slider demos by Enzo Mangano at reactiive.io. Implemented from scratch for this package.
MIT © Asad Ali
