Skip to content

Slider - Frameworks

Sliders allow users to adjust a numeric value within a given range.

AndroidreleasediOSreleasedReactreleasedReact 19releasedVuereleased

iOS

Syntax

Using range

swift
Warp.Slider(
    value: Binding<Double>,
    range: ClosedRange<Double>,
    step: Double = 1.0,
    showTooltips: Bool = true,
    showRange: Bool = false,
    enabled: Bool = true,
    onEditingChanged: ((Double) -> Void)? = nil
)
swift
Warp.Slider(
    value: $sliderValue,
    range: 0.0...100.0,
    step: 1.0
)

Using array

swift
Warp.Slider(
    selectedItem: Binding<ArrayElement>,
    items: Array<ArrayElement>,
    showTooltips: Bool = true,
    showRange: Bool = false,
    enabled: Bool = true,
    valueFormat: ((ArrayElement) -> String)? = nil
)
swift
    @State private var selectedItem = "Medium"
    let items = ["Small", "Medium", "Large"]
    Warp.Slider(selectedItem: $selectedItem, items: items)

Legacy support

By default all Warp components return a SwiftUI View but there is always a UIKit UIView available to use also.

swift
Warp.Slider(
    value: $sliderValue,
    range: 0.0...100.0,
    step: 1.0
).uiView

Parameters

Required props

NameTypeDefaultDescription
valueBinding DoubleBinding value to update the slider value
rangeClosedRange DoubleDefines the range for the slider

Optional Props

NameTypeDefaultDescription
stepDouble1.0The increment by which the slider value should change.
showTooltipsBooltrueWhether to show tooltips above the thumbs.
showRangeBoolfalseWhether to show min/max range indicators.
enabledBooltrueWhether the slider is enabled or disabled.
valueFormatter(Double) -> StringnilA closure that formats the displayed value. Defaults to a simple string conversion.
onEditingChanged((Double) -> Void)?nilA closure that is called when the slider's thumb is released, passing the final value as an argument.
selectedItemBinding (where T: LosslessStringConvertible & Equatable)For discrete sliders: a binding to the currently selected item from the list.
itemsArray (where T: LosslessStringConvertible & Equatable)For discrete sliders: an array of items to choose from.

Questions?

Feel free to ask any questions on usage in the Warp DS Slack channel: #warp-design-system