Slider

Pick a value by dragging a thumb along a track.

A value picker driven by a single thumb. The thumb and the fill are animated on the UI thread, so dragging never round-trips through React; the picked value bridges back on change and again on release.

Installation

Slider ships with the library — no separate install.

import { Slider } from 'panelui-native';

Or copy the source into your project, to own and edit it:

npx panelui-cli@latest add slider

Usage

<Slider defaultValue={40} />
<Slider value={volume} onValueChange={setVolume} />
<Slider min={0} max={10} step={1} defaultValue={5} />

Examples

Controlled

Hold the value in state and read it back for a live label.

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

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

Range and step

min, max and step bound the value and snap it to fixed increments.

<Slider min={0} max={10} step={1} defaultValue={5} />

Commit on release

onValueChange tracks the drag; onValueCommit fires once at the end — the place for a network write.

<Slider
  defaultValue={50}
  onValueChange={setPreview}
  onValueCommit={save}
/>

Disabled

<Slider defaultValue={30} disabled />

Variants

color

  • primary (default)
  • success
  • warning
  • destructive
  • info
<Slider color="primary" defaultValue={40} />
<Slider color="success" defaultValue={40} />
<Slider color="warning" defaultValue={40} />
<Slider color="destructive" defaultValue={40} />
<Slider color="info" defaultValue={40} />

size

  • sm
  • md (default)
  • lg
<Slider size="sm" defaultValue={40} />
<Slider size="md" defaultValue={40} />
<Slider size="lg" defaultValue={40} />

API Reference

Slider

PropTypeDefaultDescription
classNamestring
valuenumberControlled value. Leave unset and pass defaultValue to run uncontrolled.
defaultValuenumber0Starting value when uncontrolled.
minnumber0Lower bound.
maxnumber100Upper bound.
stepnumber1Snap granularity. The value is always a multiple of step from min.
onValueChange(value: number) => voidFires on every change while dragging — cheap updates only.
onValueCommit(value: number) => voidFires once when the gesture ends — the place for expensive side effects.
disabledbooleanfalse
trackClassNamestringExtra classes for the unfilled track.
fillClassNamestringExtra classes for the filled portion.
thumbClassNamestringExtra classes for the draggable thumb.

Every part also accepts the underlying React Native props (ViewProps or TextProps) and a className for Tailwind utilities.

Notes

Runs controlled (value + onValueChange) or uncontrolled (defaultValue). onValueChange fires on every frame of a drag; onValueCommit fires once on release — reach for it when the change is expensive. The value is always snapped to a multiple of step from min.

On this page