Height picker
A ruler you scroll under a fixed pointer to set a height, with an accent fill, a large rolling value and a centimetres or feet and inches switch.
npx @swipeui/cli add height-pickerWhen to use it
- Asking for a height in onboarding, a health profile or a fitness goal.
- Any length a person finds on a ruler faster than they type it.
When not to use it
- A value with no natural scale, such as a quantity: use Number field or Stepper.
- A percentage or a volume: use Slider.
Installation
Installs with a Pro licence
Everything on this page is public except the source. Founder pre-sale opens around 5 January 2027.
Usage
import { HeightPicker } from '@/components/swipeui/special/height-picker';
<HeightPicker defaultValue={172} onValueCommit={(cm) => saveHeight(cm)} />;The value is always centimetres. The unit switch changes what is shown, never what is stored, so switching back and forth can't drift.
Examples
- Onboarding: a tall ruler with the value beside it and the unit switch below.
- Units: start in feet and inches with
defaultUnit="ft"; feet step by one inch. - Compact:
orientation="horizontal"puts a wide ruler in a form row, withprecision={0.1}for tenths.
Height picker settings
| Prop | Does | Default |
|---|---|---|
| value, defaultValue | The height in centimetres | 170 |
| onValueChange | Every new step while the ruler moves | — |
| onValueCommit | Once, when the ruler settles | — |
| unit, defaultUnit | cm or ft | cm |
| onUnitChange | The switch was used | — |
| unitSwitch | Show the unit switch | true |
| min, max | The range in centimetres | 100, 220 |
| precision | The centimetre step, 1 or 0.1 | 1 |
| fill | Accent ticks below the value | true |
| readout | The large rolling value | true |
| momentum | Carry on after a flick and land on a step | true |
| rubberBand | Stretch past the ends | true |
| fineScrub | Slow down by moving across the ruler | true |
| orientation | vertical or horizontal | vertical |
| length | A vertical ruler's height in points | 320 |
| tickSpacing | Points between ticks | 10 (6 with tenths) |
| formatValue | Replaces the readout text | — |
| label | The spoken name | Height |
| locale | The locale for the digits | Device |
| disabled | Show without changing | false |
| haptics | A switch, or { tick, major, limit, unit } | true |
| messages | Built-in strings | English |
| motion | Local motion feel | App feel |
Composition and behavior
Drag the ruler and the value under the pointer changes, with a tick on each step and a light tap at every ten centimetres or every foot. A flick carries on and lands on a step. Past the shortest and tallest heights the ruler stretches, then springs back. While dragging, move your finger across the ruler to slow it to half, quarter and eighth speed.
Screen readers get one adjustable element named Height, with a value such as "172 centimetres" or "5 feet 8 inches"; swipe up or down to step. With Reduce Motion the ruler still follows the finger and then lands at once.
Put the vertical ruler on a screen that doesn't scroll under it, and wrap the app in GestureHandlerRootView. Only the ticks near the value are mounted, so tenths cost the same as whole centimetres. The public demonstration is written separately for the browser.
Behavior and gestures
- Drag the ruler: the value under the pointer changes with a tick per step and a tap at every ten centimetres or every foot.
- Flick it and it carries on, then lands on a step. The ends stretch and spring back.
- Move the finger across the ruler while dragging to slow it to half, quarter and eighth speed.
- The switch shows centimetres or feet and inches. The stored height is always centimetres, so switching never changes it.
Accessibility
- The ruler is one adjustable element named Height, with a spoken value such as 172 centimetres or 5 feet 8 inches; swipe up and down to step.
- The ticks and the large readout are hidden from screen readers; fine-scrub rate changes are announced.
- The unit switch is a named group of two tabs.
Motion
- Uses the
drag,numberandselectmotion roles, so it follows your app's feel. Passmotionto tune this one instance. - The ruler follows the finger and glides to a projected step on the drag role, with overshoot clamped.
- The readout rolls on the number role; the unit switch's highlight glides on the select role.
- Reduce Motion: the ruler still follows the finger, then lands at once; the readout swaps.
Performance
- Only the ticks near the value are mounted, so tenths over a 120cm range cost the same as whole centimetres.
- The ruler moves on the UI thread; React hears about a new value once per step.
Notes for AI
- value, min and max are always centimetres. Use onValueCommit to save and onValueChange for live previews.
- Wrap the screen in GestureHandlerRootView. Put the vertical ruler on a screen that does not scroll under it.
- precision is 1 or 0.1 centimetres; feet always step by one inch.
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.