Expo UI and Router for iOSExpo SDK 57 and later, iOS only
Components

Slider

A SwiftUI Slider component for selecting values from a range.

Expo UI Slider matches the official SwiftUI Slider API and allows selecting values from a bounded range.

Usage

Note: Slider is a flexible-width component, it expands to fill available horizontal space and does not have an intrinsic width. When using matchContents on the Host, you should apply a frame modifier on the Slider to give it an explicit width. Alternatively, give the Host an explicit size using style (for example, style={{ width: 300 }} or style={{ flex: 1 }}), or place the Slider inside a SwiftUI container like Form that provides width constraints.

Basic slider

import { useState } from 'react';
import { Host, Slider } from '@expo/ui/swift-ui';

export default function BasicSliderExample() {
  const [value, setValue] = useState(0.5);

  return (
    <Host style={{ flex: 1 }}>
      <Slider value={value} onValueChange={setValue} />
    </Host>
  );
}
A slider with its thumb at the midpoint of the track
A slider with its thumb at the midpoint of the track

Slider with custom range

import { useState } from 'react';
import { Host, Slider } from '@expo/ui/swift-ui';

export default function CustomRangeSliderExample() {
  const [value, setValue] = useState(75);

  return (
    <Host style={{ flex: 1 }}>
      <Slider
        value={value}
        min={0}
        max={100}
        onValueChange={setValue}
      />
    </Host>
  );
}
A slider over a range of 0 to 100 with its thumb three quarters of the way along
A slider over a range of 0 to 100 with its thumb three quarters of the way along

Slider with step

Use the step prop to define discrete increments. Set step to 0 for continuous values.

import { useState } from 'react';
import { Host, Slider } from '@expo/ui/swift-ui';

export default function SteppedSliderExample() {
  const [value, setValue] = useState(0);

  return (
    <Host style={{ flex: 1 }}>
      <Slider
        value={value}
        min={0}
        max={100}
        step={10}
        onValueChange={setValue}
      />
    </Host>
  );
}
A slider with its thumb at the far left, at the minimum value of zero
A slider with its thumb at the far left, at the minimum value of zero

Slider with labels

You can add labels to describe a slider's purpose and to mark the minimum and maximum value positions.

import { useState } from 'react';
import { Host, Slider, Text } from '@expo/ui/swift-ui';

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

  return (
    <Host style={{ flex: 1 }}>
      <Slider
        value={value}
        min={0}
        max={100}
        label={<Text>Volume</Text>}
        minimumValueLabel={<Text>0</Text>}
        maximumValueLabel={<Text>100</Text>}
        onValueChange={setValue}
      />
    </Host>
  );
}
A slider flanked by a 0 label on the left and a 100 label on the right
A slider flanked by a 0 label on the left and a 100 label on the right

API

import { Slider } from '@expo/ui/swift-ui';

Component

Slider

Type: React.Element<SliderProps>

SliderProps

label

Optional • Type: ReactNode

A label describing the slider's purpose.

lowerLimit

Optional • Type: number

Lower limit the user can drag the thumb to. The visible track still spans min..max, but the thumb stops at lowerLimit during drag.

max

Optional • Type: number

The maximum value of the slider. Updating this value does not trigger callbacks if the current value is above max.

maximumValueLabel

Optional • Type: ReactNode

A label displayed at the maximum value position.

min

Optional • Type: number

The minimum value of the slider. Updating this value does not trigger callbacks if the current value is below min.

minimumValueLabel

Optional • Type: ReactNode

A label displayed at the minimum value position.

onEditingChanged

Optional • Type: (isEditing: boolean) => void

Callback triggered when the user starts or ends editing the slider.

onValueChange

Optional • Type: (value: number) => void

Callback triggered on dragging along the slider.

step

Optional • Type: number

The step increment for the slider.

upperLimit

Optional • Type: number

Upper limit the user can drag the thumb to. The visible track still spans min..max, but the thumb stops at upperLimit during drag.

value

Optional • Type: number

The current value of the slider.

Inherited props

Modifiers

Use these modifiers in the modifiers prop of the SwiftUI and Universal version. The Drop-in version does not accept modifiers.

Expo UI lets you put any of the 89 modifiers for any view on Slider, but not all of them do something here.

  • 48 change what you see on Slider.
  • 1 work, but not in the way that you may expect.
  • 28 have no visible effect on Slider.
  • 13 work only in one place, such as a widget or a Grid.

Best modifiers for Slider

These modifiers are made for Slider, or they are the ones that you use most with it.

Also works on Slider

Slider takes these modifiers too, and each one works in the usual way.

Needs care on Slider

These modifiers work on Slider, but not in the way that you may expect.

ModifierWhat to know
animationThe Slider animates its own thumb. Use this for the other modifiers on the slider.

No visible effect on Slider

Slider accepts these modifiers, but you see no change. They do not give an error.

ModifierWhy nothing happens
accessibilityElementIt joins the child views into one accessibility element, and Slider takes no child views.
allowsTighteningIt changes only text, and Slider shows no text.
boldIt changes only text and SF Symbols, and Slider shows neither.
containerShapeIt sets the shape that the child views use for containerRelativeShape, and Slider takes no child views.
contentTransition iOS 16+It changes how text and SF Symbols animate when their content changes, and Slider shows neither.
dynamicTypeSizeIt changes only text and SF Symbols, and Slider shows neither.
fontIt changes only text and SF Symbols, and Slider shows neither.
geometryGroup iOS 17+It works on the child views that you give the component, and Slider takes none.
imageScaleIt changes only SF Symbols, and Slider shows none.
italicIt changes only text, and Slider shows no text.
kerningIt changes only text, and Slider shows no text.
layoutPriorityIt has an effect only when the view shares an axis with other views in a stack.
lineHeight iOS 26+It changes only text, and Slider shows no text.
lineLimitIt changes only text, and Slider shows no text.
lineSpacingIt changes only text, and Slider shows no text.
minimumScaleFactorIt changes only text, and Slider shows no text.
monospacedDigitIt changes only text, and Slider shows no text.
multilineTextAlignmentIt changes only text, and Slider shows no text.
onAppearIn SDK 57, Slider does not send modifier events to JavaScript, so the handler does not run.
onDisappearIn SDK 57, Slider does not send modifier events to JavaScript, so the handler does not run.
onGeometryChangeIn SDK 57, Slider does not send modifier events to JavaScript, so the handler does not run.
onLongPressGestureIn SDK 57, Slider does not send modifier events to JavaScript, so the handler does not run.
onTapGestureIn SDK 57, Slider does not send modifier events to JavaScript, so the handler does not run.
strikethroughIt changes only text, and Slider shows no text.
textCaseIt changes only text, and Slider shows no text.
truncationModeIt changes only text, and Slider shows no text.
underlineIt changes only text, and Slider shows no text.
zIndexIt changes the order of views that cover each other in the same parent, and Slider does not stack its children.

Only in some places

These modifiers work only in a widget, in a Grid, in a Namespace or in a parent that asks for them.

ModifierWhere it works
activityBackgroundTintWorks only in a Live Activity. It has no effect in the app.
alignmentGuideHas an effect only when the parent, such as a VStack or ZStack, aligns its children by the same guide.
containerBackgroundWorks only in a widget, or in a navigation container when you use a navigation placement.
glassEffectIdWorks only on a view that also has glassEffect, in a GlassEffectContainer and a Namespace.
gridCellAnchor iOS 16+Works only on a cell of a Grid. Grid is in @expo/ui/swift-ui, but it has no Expo docs page.
gridCellColumnsWorks only on a view in a Grid.Row. Grid is in @expo/ui/swift-ui, but it has no Expo docs page.
gridCellUnsizedAxesWorks only on a view in a Grid. Grid is in @expo/ui/swift-ui, but it has no Expo docs page.
gridColumnAlignment iOS 16+Works only on a view in a Grid.Row. Grid is in @expo/ui/swift-ui, but it has no Expo docs page.
invalidatableContent iOS 17+Has an effect only when a parent view uses redacted with the invalidated reason.
matchedGeometryEffectWorks only in a Namespace. Give two views the same id and change between them with an animation.
privacySensitiveHas an effect only when a parent view uses redacted with the privacy reason.
unredactedHas an effect only in a parent view that uses redacted.
widgetURLWorks only in a widget. It has no effect in the app.

Sources

The original Expo docs for this page:

  • Slider (SwiftUI) (source-of-truth/versions/v57.0.0/sdk/ui/swift-ui/slider.md)
  • Slider (Universal) (source-of-truth/versions/v57.0.0/sdk/ui/universal/slider.md)
  • Slider (Drop-in) (source-of-truth/versions/v57.0.0/sdk/ui/drop-in-replacements/slider.md)

On this page