Structure¶
Slider¶
A control for selecting a value from a bounded range.¶
Declaration¶
struct Slider<Label, ValueLabel> : View where Label : View, ValueLabel : View
Overview¶
A slider is a circle on a track. The user can move the circle from left to right to pick between values. The slider takes a binding that the user updates.
The most basic example looks like this:
struct SliderView: View {
@State private var value: Double = 0
var body: some View {
Slider(value: $value)
}
}

In general, a slider has these four options:
- Add a label
- Change maximum and minimum values
- Create a step size
- Call a function when slider editing changes.
The slider's different initializers use different combinations of these options.
Availability¶
iOS 13.0+
macOS 10.15+
watchOS 6.0+
Topics¶
Instance Property¶
body The content and behavior of the view.
Type Alias¶
Body The type of view representing the body of this view.
Initializer¶
init(value:in:onEditingChanged:) Creates a slider.
init(value:in:onEditingChanged:label:) Creates a slider with a label.
init(value:in:onEditingChanged:minimumValueLabel:maximumValueLabel:label:) Creates a slider with a label and max/min labels.
init(value:in:step:onEditingChanged:) Creates a slider with a step size.
init(value:in:step:onEditingChanged:label:) Creates a slider with a label and a step size.
init(value:in:step:onEditingChanged:minimumValueLabel:maximumValueLabel:label:) Creates a slider with a label, max/min labels, and a step size.