rslabdocs

Slider

A gesture-driven value slider: the thumb tracks your finger 1:1, with a haptic tick every 10% of travel.

ReanimatedGesture HandlerHapticsSource

Prerequisites

Slider needs a pan gesture on top of Reanimated and haptics.


npx expo install react-native-reanimated expo-haptics react-native-gesture-handler react-native-css

Install


npx @rslab/cli add slider

Usage

import { Slider } from '@/components/ui/Slider';

const [volume, setVolume] = useState(0.6);

<Slider value={volume} onValueChange={setVolume} />;
<Slider
  value={volume}

  onValueChange={setVolume}

  onSlidingComplete={(v) => saveVolume(v)}
/>

Props

PropTypeDefault
value
number
-

Controlled, 0 to 1. Scale it yourself for a different range, e.g. value / 100 in, Math.round(v * 100) out.

onValueChange
(value: number) => void
-

Fires continuously while dragging.

onSlidingComplete?
(value: number) => void
-

Fires once, when the finger lifts.

disabled?
boolean
false

Fades the slider and blocks the gesture.

haptic?
boolean
true

Tick every 10% of travel. Set false to mute it.

className?
string
-

Extend or override the outer wrapper.

See exactly how this works with an RSLAB subscription.

Get Pro

On this page