Range Slider

React Native

A bar thumb that glides between steps.

Preview

It works in Expo and in bare React Native. New to beUI Native? Set up your app first.

$ bunx beui-native add range-slider

Copies the component and the shared files it needs into src/, adds the theme tokens if they're missing, and installs its libraries. Files you've changed are kept.

Documentation

Native port of beUI Range Slider. A stepped slider with tick dots and a bar thumb that glides between steps and stretches while held.

import { RangeSlider } from "./src";

const [value, setValue] = useState(40);

<RangeSlider
  value={value}
  onValueChange={setValue}
  step={5}
  accessibilityLabel="Value"
/>

Props

  • value / defaultValue / onValueChange: controlled or uncontrolled. onValueChange fires once per step while dragging, so it's the place for a selection haptic.
  • onSlidingComplete: the final value when a drag or tap lets go.
  • min, max, step: default to 0, 100 and 1. When the step doesn't divide the range, the end of the track still reaches max.
  • showTicks: a dot at each step. Defaults to true, and hides itself past 50 steps.
  • formatValueText: what screen readers hear instead of the raw number, such as `(v) => ${v}% `.
  • disabled, disableAnimation, className.

Touch

Drag or tap anywhere on the track; the thumb lands under your finger. Horizontal drags own the slider and vertical swipes go on to scroll the page, so it works inside a ScrollView.

Motion

The thumb and fill follow beUI's glide spring, critically damped so they never rebound off an end. While held, the thumb stretches to 135% on a bouncy spring. With reduced motion, or disableAnimation, both move straight to the value and the thumb doesn't stretch.

Accessibility

The track is one adjustable control (a slider on web) with its range, value and value text. VoiceOver and TalkBack swipe up and down to step it; on web, arrow keys step it, Page Up and Down move ten steps, and Home and End jump to the ends. Give it an accessibilityLabel.

Copy this directory, hooks/use-reduced-motion.ts, styles/motion.ts, and the semantic tokens in styles/theme.css.

Also on the web. The React version of Range Slider, built with Motion and Tailwind CSS.