Skip to Content
ARCUI

Slider

Controlled single-value or range slider with UI-thread gesture motion, snapped live callbacks, commit callbacks, and native adjustable accessibility semantics.

Slider is a controlled numeric selection primitive with separate single-value and range modes. Continuous gesture motion stays on the UI thread while JavaScript receives only meaningful semantic value changes.

Usage

Single value

import { Slider } from "react-native-arc-ui";
import { useState } from "react";

export function VolumeSlider() {
  const [value, setValue] = useState(50);

  return (
    <Slider
      label="Volume"
      value={value}
      onValueChange={setValue}
      onValueCommit={(finalValue) => saveVolume(finalValue)}
    />
  );
}

Range

const [values, setValues] = useState<[number, number]>([20, 80]);

<Slider
  range
  label="Budget"
  values={values}
  onValuesChange={setValues}
  onValuesCommit={(finalRange) => saveRange(finalRange)}
/>;

Single and range mode are structurally different public states. A mounted Slider must not switch between them; remount with a different key if the semantic mode genuinely changes.

Controlled ownership

Slider never owns the public semantic value. The consumer remains the source of truth through value or values.

During an active gesture, ARCUI temporarily gives visual SharedValues priority so the thumb can move continuously without waiting for JS. When the interaction completes, the latest controlled prop becomes authoritative again.

This means a consumer may accept, transform, clamp further, or reject a requested value without destabilizing the gesture path.

Live change vs commit

ARCUI intentionally separates live semantic updates from completed interactions.

Live change

onValueChange / onValuesChange are optional. They fire while the user interacts only when the snapped public value actually changes.

<Slider value={value} onValueChange={setValue} />

They are not called for every gesture frame. Visual motion continues at display refresh rate on the UI thread regardless of whether a live callback is provided.

Commit

onValueCommit / onValuesCommit fire once after a successful user interaction that finishes on a different semantic value.

<Slider
  value={value}
  onValueChange={setValue}
  onValueCommit={(finalValue) => {
    analytics.track("volume_changed", { value: finalValue });
    persistVolume(finalValue);
  }}
/>

Commit is the preferred boundary for persistence, network work, analytics, or other side effects that only need the final value.

If an interaction returns to its starting semantic value, there is nothing to commit.

Range configuration

<Slider
  min={0}
  max={10}
  step={0.5}
  value={value}
  onValueChange={setValue}
/>

Defaults:

min  = 0
max  = 100
step = 1

The step grid is anchored to min, not zero.

max is always a valid terminal value even when the range is not evenly divisible by step.

For example:

min = 0
max = 10
step = 3

valid semantic values:
0, 3, 6, 9, 10

Runtime numeric configuration degrades safely:

  • non-finite min falls back to 0;
  • non-finite max falls back to the resolved min;
  • max < min collapses the Slider to min;
  • invalid/non-positive step falls back to 1;
  • non-finite values resolve deterministically to the valid range.

Development builds also report diagnostics for invalid configuration.

Range normalization

Range values are independently snapped/clamped and then ordered lower-to-upper.

<Slider range values={[80, 20]} />

resolves visually and semantically as the normalized range [20, 80] for the active configuration.

The two thumbs never cross during interaction.

Header layouts

layout controls the information displayed around the Slider.

label-value   // default
label-minmax
minmax
none
<Slider label="Volume" layout="label-value" value={value} />
<Slider label="Temperature" layout="label-minmax" value={value} />
<Slider layout="minmax" value={value} />
<Slider layout="none" value={value} />

Tooltip

showTooltip defaults to true.

While a thumb is actively manipulated, ARCUI can show the current snapped value above that thumb.

<Slider value={value} showTooltip={false} />

Tooltip visibility, scale, and text update are kept off the React frame path. Reduced Motion removes tooltip/thumb geometric scaling while preserving interaction feedback.

Disabled and inactive

<Slider value={40} disabled />
<Slider value={40} active={false} />
  • disabled represents fully disabled semantics;
  • active={false} keeps the inactive ARCUI presentation while preventing interaction.

A collapsed Slider where max <= min is also non-interactive because there is no selectable range.

Validation

A non-empty error string renders ARCUI validation feedback below the control.

<Slider
  label="Minimum score"
  value={score}
  onValueChange={setScore}
  error={score < 50 ? "Choose at least 50" : undefined}
/>

The error row is exposed as a polite native alert and uses ARCUI input validation typography/colors for consistency with the field family.

Styling

style applies to the Slider root container.

<Slider
  value={value}
  onValueChange={setValue}
  style={{ marginTop: 16 }}
/>

Thumb size, touch target, track height, tooltip geometry, radius, colors, and motion should normally be configured through Slider tokens rather than repeated per-instance styles.

Testing

Use testID on the public Slider root.

<Slider
  testID="price-slider"
  value={value}
  onValueChange={setValue}
/>

Stable descendants include:

price-slider-track
price-slider-thumb
price-slider-thumb-tooltip
price-slider-error-row
price-slider-error

Range mode uses:

price-slider-thumb-lo
price-slider-thumb-lo-tooltip
price-slider-thumb-hi
price-slider-thumb-hi-tooltip

Header descendants are also derived from the root testID when the selected layout renders them:

price-slider-label
price-slider-value
price-slider-minmax
price-slider-min
price-slider-max

For provider setup and the dedicated react-native-arc-ui/testing entrypoint, see Testing.

API Reference

Single Slider

PropTypeDefaultDescription
min?number0Minimum selectable value.
max?number100Maximum selectable value.
step?number1Value increment. Step is anchored to min.
label?string—Optional Slider label.
error?string—Optional validation error.
layout?TSliderLayout"label-value"Header layout.
showTooltip?booleantrueShows the active-thumb tooltip while interacting.
disabled?booleanfalseDisables Slider interaction and exposes disabled accessibility state.
active?booleantrueWhether the Slider is active. Inactive Slider remains visible but is not interactive.
style?StyleProp<ViewStyle>—Consumer container style.
accessibilityHint?string—Optional additional accessibility guidance. ARCUI does not provide a generic gesture instruction by default.
testID?string——
range?falsefalseSingle-value mode.
valuenumberrequiredCurrent semantic value. Slider is controlled. The consumer is the source of truth.
onValueChange?(value: number) => void—Optional live semantic-change callback. Called while the user interacts only when the snapped value changes. It is not called for every gesture frame; visual Slider motion remains UI-thread driven independently of this callback.
onValueCommit?(value: number) => void—Called once after a successful user interaction that changed the semantic value completes. Use this for persistence, network work, analytics, or other work that should happen only after the final value is known.
accessibilityLabel?string—Accessibility label for the adjustable thumb. Falls back to label, then to the localized ARCUI Slider label.

Range Slider

PropTypeDefaultDescription
min?number0Minimum selectable value.
max?number100Maximum selectable value.
step?number1Value increment. Step is anchored to min.
label?string—Optional Slider label.
error?string—Optional validation error.
layout?TSliderLayout"label-value"Header layout.
showTooltip?booleantrueShows the active-thumb tooltip while interacting.
disabled?booleanfalseDisables Slider interaction and exposes disabled accessibility state.
active?booleantrueWhether the Slider is active. Inactive Slider remains visible but is not interactive.
style?StyleProp<ViewStyle>—Consumer container style.
accessibilityHint?string—Optional additional accessibility guidance. ARCUI does not provide a generic gesture instruction by default.
testID?string——
rangetruerequiredEnables two-thumb range mode.
valuesTSliderRangeValuerequiredCurrent semantic [lower, upper] values. Slider is controlled. The consumer is the source of truth.
onValuesChange?(values: [number, number]) => void—Optional live semantic-change callback. Called while the user interacts only when a snapped lower or upper value changes. It is not called for every gesture frame; visual Slider motion remains UI-thread driven independently of this callback.
onValuesCommit?(values: [number, number]) => void—Called once after a successful user interaction that changed the semantic range completes.
lowerAccessibilityLabel?string—Accessibility label for the lower thumb. Falls back to the localized ARCUI lower-value label.
upperAccessibilityLabel?string—Accessibility label for the upper thumb. Falls back to the localized ARCUI upper-value label.

Generated from the ARCUI 1.1.x TypeScript source snapshot. Native inherited props remain available through the referenced React Native surface.

The generated table reflects the discriminated single-value and range public API.

Motion

Slider is intentionally UI-thread-first.

During a drag:

  • thumb position is a SharedValue;
  • active track geometry follows SharedValues;
  • range-thumb crossing constraints run in the gesture worklet;
  • tooltip position/text follows UI-thread state;
  • thumb/tooltip visual feedback stays independent from JS load.

JavaScript is crossed only for semantic step transitions when a live callback exists, and once for a meaningful completed interaction.

Controlled prop changes outside an active gesture animate toward their new semantic positions. Active gestures temporarily own visual position so prop updates cannot fight the finger and introduce jitter.

See Motion and State ownership.

Performance

The common commit-only path performs no UI-to-JS work while the finger is moving.

If onValueChange / onValuesChange are provided, ARCUI crosses to JS only when the snapped value changes—not for raw gesture frames. This preserves a useful live semantic API without making React the animation driver.

Use commit callbacks for expensive work whenever live feedback is unnecessary.

See Performance.

Accessibility

Each Slider thumb exposes native adjustable semantics with increment/decrement accessibility actions.

Single-value semantics

accessibilityLabel resolves in this order:

explicit accessibilityLabel
-> label
-> localized ARCUI Slider label

Range semantics

Use lowerAccessibilityLabel and upperAccessibilityLabel. When omitted, ARCUI provides localizable lower/upper labels and incorporates label when available.

Accessibility increment/decrement is treated as one complete discrete semantic interaction, so change and commit semantics are delivered together.

The real semantic value is exposed through accessibilityValue.text. ARCUI uses a normalized integer scale internally for React Native's numeric accessibilityValue requirements, including decimal Slider values.

accessibilityHint is available for application-specific guidance. ARCUI intentionally does not inject a generic gesture instruction.

See Accessibility.

Theming

Relevant token areas include:

colors.light.slider
colors.dark.slider
sizings.slider
radius.slider
typography.slider
sliderAnimations
animations

Slider also reuses ARCUI input label/error presentation for field-family consistency.

sliderAnimations controls Slider-specific motion such as semantic-position timing, active thumb scale, and tooltip scale-from behavior, with global animation tokens used as fallback where defined.

Top-level token overrides are shallow. Compose changed namespaces from defaultTokens.

import { ARCUI, defaultTokens, type TTokensOverride } from "react-native-arc-ui";

const tokens = {
  sliderAnimations: {
    ...defaultTokens.sliderAnimations,
    thumbScale: 1.15,
    tooltipScaleFrom: 0.9,
  },
} satisfies TTokensOverride;

export function App() {
  return <ARCUI tokens={tokens}>{/* application */}</ARCUI>;
}

See Tokens and Theming.

Try it live

Explore Slider interactively in Expo Snack.

Open Slider in Expo Snack ↗

On this page