RulerPicker

RulerPicker is an animated ruler picker component for React Native and React, from the dissolve library. Horizontal ruler with momentum, rolling value and a haptic tick per graduation.

A horizontal ruler you drag under a center needle: 1:1 pan, momentum, then a calm snap on the nearest step. The value rolls above it. Graduations near the needle stretch with speed, and a haptic tick lands on every step.

Install

React Native

Install the engine once per app and wrap the root layout in <DissolveProvider> (see Installation), then copy the component into components/dissolve:

npx expo install dissolve-ui @shopify/react-native-skia react-native-reanimated react-native-worklets react-native-gesture-handler expo-haptics
npx dissolve-ui add ruler-picker --native
npx shadcn@latest add https://dissolve.rselmi.com/r/native/ruler-picker.json

React

Needs React 19 and react-dom, nothing else: no engine, no provider, no Tailwind. Works in the Next.js App Router.

npx dissolve-ui add ruler-picker --web
npx shadcn@latest add https://dissolve.rselmi.com/r/ruler-picker.json

Usage

RulerPicker.tsx (React Native)
import { RulerPicker } from '@/components/dissolve/ruler-picker';

<RulerPicker
  value={kg}
  onChange={setKg}
  min={30}
  max={200}
  step={0.1}
  unit="kg"
/>
RulerPicker.tsx (React)
import { RulerPicker } from '@/components/dissolve/ruler-picker';

<RulerPicker
  value={kg}
  onChange={setKg}
  min={30}
  max={200}
  step={0.1}
  unit="kg"
/>

Props

PropTypeDefaultDescription
valuenumberrequiredCurrent value. An outside change glides the ruler to it.
onChange(value: number) => voidCalled once the ruler is at rest on a new value.
onChanging(value: number) => voidCalled on every step crossed while dragging or gliding.
min / maxnumberrequiredBounds. Past them the ruler follows with a 0.3 rubber band.
stepnumber1Value between two graduations.
majorEverynumber10A labelled major graduation every N steps.
unitstringUnit next to the value, e.g. 'kg'.
format(value: number) => stringFormats the labels and the accessibility value.
tickSpacingnumber10Distance between two graduations, pt.
heightnumber76Ruler height.
showValuebooleantrueShows the rolling value above the ruler.
fontSizenumber56Value size.
hapticsbooleantrueA tick per step, light on majors, rigid at the bounds.
classNamestringRoot classes (margins, width...).
valueClassNamestringValue classes, passed to NumberTicker.

Source

Previous: QuantityStepper · Next: BarChart · All components

dissolve is MIT licensed. Source on GitHub, package on npm. This page as markdown. For AI agents: llms.txt.