SwipeUI

Elastic slider

A slider that stretches with resistance past its ends, grows its thumb, trails a leaning value tag and holds on detents; ★ the end icon swells with the pull.

npx @swipeui/cli add elastic-slider
Variant
Preset
Material
Scheme
Feel
Real free component with a browser animation bridge. Native motion, haptics and materials need a device.

When to use it

  • Sliders that should feel physical, stretching a little when pushed past the end.
  • Playful settings such as playback speed or a mood scale.
  • Range sliders that should signal the limits clearly.

When not to use it

  • Dense forms where a calm slider suits better. Use Slider.
  • Precise values. Use Number field.

Installation

Run this from your app's root. If SwipeUI isn't set up yet, run npx @swipeui/cli init first; it sets up Uniwind, the theme tokens and the cn helper.

npx @swipeui/cli add elastic-slider
  • Adds components/swipeui/ui/elastic-slider.tsx and 14 shared helpers.
  • Installs clsx, tailwind-merge, react-native-reanimated, react-native-worklets, uniwind, expo-haptics, class-variance-authority, react-native-svg, react-native-gesture-handler. In Expo apps it uses npx expo install so versions match your SDK.

Usage

app/player.tsx
import { ElasticSlider } from '@/components/swipeui/ui/elastic-slider';

<ElasticSlider label="Volume" defaultValue={60} startAdornment={QuietIcon} endAdornment={LoudIcon} />;

Examples

Playback speed that holds at 1× and 1.5×:

<ElasticSlider
  label="Playback speed"
  min={0.5}
  max={2}
  step={0.05}
  detents={[1, 1.5]}
  formatValue={(v) => `${v}×`}
/>

API reference

ElasticSliderProps

PropTypeDefaultDescription
value?SliderValue—

The value (controlled): a number, or [low, high] for a range.

defaultValue?SliderValue0

The value it starts with (uncontrolled).

onValueChange?((value: SliderValue) => void)—

Reports each new step while dragging, tapping or adjusting.

onValueCommit?((value: SliderValue) => void)—

Reports once when a drag, fling, tap or adjustment settles.

min?number0

Lowest value.

max?number100

Highest value; must exceed min.

step?number1

The step values snap to.

range?booleanthe shape of `value`/`defaultValue`

A range with two thumbs.

label?string'Value'

The visible and spoken name.

formatValue?((value: number) => string)String

Writes a value for the readout, the bubble and screen readers.

momentum?booleantrue

A fling carries the value on and snaps to a step.

showValue?booleantrue

The value beside the label, rolling its digits.

marks?readonly SliderMark[]—

Marks on the track; labelled marks can be pressed to set the value.

minGap?number0

A range's thumbs stay at least this far apart.

trackPress?"jump" | "none" | "step"'jump'

A press on the track jumps there, takes one step toward it, or does nothing.

fineScrub?booleantrue

★ Drag away from the track to slow the rate to ½, ¼ and ⅛, with a tick and an announcement per band.

grow?booleantrue

The thumb grows while held.

startAdornment?SliderAdornment—

An icon before the track.

endAdornment?SliderAdornment—

An icon after the track.

size?"lg" | "md" | "sm"'md'

Track and thumb size.

children?React.ReactNode—

Content drawn above the track, such as a histogram.

disabled?booleanfalse

No changes.

haptics?boolean | SelectionHapticstrue

Haptics: a switch, or per part (detent per step and scrub band, limit at the ends).

motion?MotionOverridethe app's feel

Thumb, bubble and fling motion (select, drag and number roles).

messages?Partial<SliderMessages>English

Built-in strings.

className?string—

Root classes.

style?StyleProp<ViewStyle>—

Root style.

testID?string—

Root identifier; parts append -track, -lower, -upper, -bubble-<n>, -pan, -mark-<value>.

overscroll?number | booleantrue

Past an end, the thumb and fill stretch with resistance and spring back: on, off, or the most it can pull in points.

tag?"always" | "drag" | "never"'drag'

The value tag over the thumb: while dragging, always, or never.

tagTilt?booleantrue

The tag trails the thumb on a softer spring and leans with the finger's speed (±8°).

detents?readonly number[]—

Values the thumb holds on to for a few points of travel, with a pop and a tick.

detentHold?number6

How sticky a detent is, in points.

adornmentStretch?booleantrue

★ The end icon swells as the band pulls toward it, like a system volume control.

Every Slider prop works too (momentum, marks, fine scrubbing, ranges, track presses).

Composition and behavior

  • Past either end, the thumb and the fill stretch with growing resistance and spring back on release, with one limit tick.
  • ★ Pulling past an end swells that end's icon, like a system volume control.
  • The thumb grows while held. A value tag trails it on a softer spring and leans with the finger's speed, up to 8°.
  • Detents hold the thumb for a few points of travel, with a pop and a tick.
  • Reduce Motion removes the stretch, the lean and the pop; haptics stay.
  • <Slider elastic> keeps the 1.x rubber band.

Elastic slider settings

PropDoesDefault
overscrollThe rubber band past the ends (on, off, or points)true (28pt)
tagThe value tag: drag, always or neverdrag
tagTiltThe tag trails and leans with speedtrue
detents / detentHoldValues the thumb holds on; how sticky (pt)none, 6
adornmentStretch★ The end icon swells with the pulltrue
growThe thumb grows while heldtrue
Slider propsmin, max, step, marks, momentum, fineScrub, …as Slider

Behavior and gestures

  • Drag past either end: the thumb and fill stretch with growing resistance (a rubber band) and spring back on release, with one limit tick (`overscroll`).
  • ★ Pulling past an end swells that end's icon, like a system volume control (`adornmentStretch`).
  • The thumb grows while held; a value tag trails it on a softer spring and leans with the finger's speed, up to 8° (`tag`, `tagTilt`).
  • Detents hold the thumb for a few points of travel (`detentHold`) with a pop and a tick (`detents`).
  • Everything else is Slider 2.0: momentum, marks, fine scrubbing, ranges, track presses and web keys.

Accessibility

  • Thumbs are adjustable (sliders on the web) with increment and decrement; the tag is decorative and the value is spoken through `formatValue`.
  • Detents and limits are felt as haptics and never carry meaning alone.

Motion

  • Uses the drag, select, layout, toggle and number motion roles, so it follows your app's feel. Pass motion to tune this one instance.
  • The band springs back on the select spring with the release velocity; the tag trails on the layout spring; the detent pop runs on the toggle role.
  • Reduce Motion removes the stretch, the lean, the trail and the pop; haptics stay.

Performance

  • The band, tag and pop run on the UI thread; React hears only new steps, detents and the release.

Notes for AI

  • Use it where a physical feel helps (volume, speed, brightness); use Slider for plain form values.
  • `overscroll` takes a number for a different pull; `Slider elastic` keeps the 1.x rubber band.

Compatibility

Runs onSupported
Expo SDK 57Yes
Expo SDK 58Yes
React Native CLI (with Expo modules)Yes
Expo GoYes
iOSYes
AndroidYes

This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.

Related items