SwipeUI

Range histogram slider

A range slider over a histogram of results: bars inside the range tinted, heights that spring with new data, a rolling "N results" and ★ a tick per bar crossed.

npx @swipeui/cli add range-histogram-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

  • Price filters in shopping apps that show how many items fall in each price band.
  • Filtering by distance, duration or size where the spread of results helps people choose.
  • Any two-thumb range where showing the distribution prevents empty results.

When not to use it

  • A single value. Use Slider.
  • When you don't have counts for the distribution. Use Slider with a range.

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 range-histogram-slider
  • Adds components/swipeui/ui/range-histogram-slider.tsx, components/swipeui/ui/use-range-histogram.ts and 14 shared helpers.
  • Installs react-native-reanimated, clsx, tailwind-merge, 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/filters.tsx
import { RangeHistogramSlider } from '@/components/swipeui/ui/range-histogram-slider';

<RangeHistogramSlider
  label="Price"
  data={[2, 5, 9, 14, 18, 16, 12, 9, 6, 4]}
  max={240}
  defaultValue={[40, 160]}
  formatValue={(v) => `€${v}`}
/>;

API reference

RangeHistogramSliderProps

PropTypeDefaultDescription
min?number0

Lowest value.

max?number100

Highest value; must exceed min.

step?number1

The step values snap to.

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.

bubble?"always" | "drag" | "never"'drag'

A bubble with the value over the thumb: while dragging, always, or never.

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.

limitStrain?booleantrue

Past an end, the thumb strains toward the finger and springs back, with a limit haptic.

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.

elastic?booleanfalse

1.x: rubber-band past the ends, as Elastic slider does.

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<Pick<SelectionMessages, "results">> & Partial<SliderMessages>SELECTION_MESSAGES.results

Built-in strings. The results line, for translation.

className?string—

Root classes.

style?StyleProp<ViewStyle>—

Root style.

testID?string—

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

data?readonly number[]—

How many results each bar holds, in order from min.

bins?readonly number[]—

1.x name for data.

bucketSize?numberthe span split evenly over the bars

How wide each bar is, in values.

value?readonly [number, number]—

The chosen range (controlled).

defaultValue?readonly [number, number][min, max]

The range it starts with (uncontrolled).

onValueChange?((value: readonly [number, number]) => void)—

Reports each new step.

onValueCommit?((value: readonly [number, number]) => void)—

Reports once when a gesture settles.

showCount?booleantrue

A rolling "N results" under the bars.

barTicks?booleantrue

★ A tick as each thumb crosses a bar's edge (one per bar, not per step).

barHeight?number56

The bars' height, in points.

Slider's range props work too: minGap, momentum, fineScrub, trackPress, marks, step.

Composition and behavior

  • Bars inside the range turn the primary colour; the rest stay muted. A bar counts when its middle is inside the range.
  • The "N results" line under the bars rolls its digits as the range changes.
  • ★ A tick plays as each thumb crosses a bar's edge, one per bar instead of one per step.
  • New data springs each bar to its new height.

Range histogram slider settings

PropDoesDefault
dataResults per bar, from min (1.x bins)none
bucketSizeHow wide each bar is, in valuesspan ÷ bars
showCountA rolling "N results"true
barTicks★ A tick per bar crossedtrue
barHeightThe bars' height (pt)56
value / defaultValueThe range[min, max]
Slider propsmin, max, step, minGap, formatValue, …as Slider
messagesThe results lineEnglish

Behavior and gestures

  • Drag either thumb (Slider 2.0's range: momentum, minimum gap, fine scrubbing, track presses): bars inside the range turn the primary colour and the rest stay muted.
  • The "N results" line under the bars rolls its digits as the range changes (`showCount`).
  • ★ A tick plays as each thumb crosses a bar's edge, one per bar instead of one per step (`barTicks`).
  • New `data` springs each bar to its new height.

Accessibility

  • The two thumbs are adjustable (sliders on the web), named "Label, lower value" and "Label, upper value", with increment and decrement.
  • The bars are decorative; the result count is real text.

Motion

  • Uses the select, drag, layout and number motion roles, so it follows your app's feel. Pass motion to tune this one instance.
  • Bar heights spring on the layout role; the count rolls on the number role; thumbs move as in Slider.
  • Reduce Motion: bars and digits change at once; haptics stay.

Performance

  • Tinting and counting run once per step on JS; the thumbs track on the UI thread.

Notes for AI

  • Pass `data` as one count per bar from `min` (1.x `bins` still works); `bucketSize` sets how wide each bar is.
  • The count is the sum of the bars whose middle is inside the range; use your own text with `messages.results`.

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