Slider

A component that lets users select a value from a range by dragging a thumb along a track.

Preview

Button Preview

Code Example

let model = SliderVM {
  $0.style = .striped
  $0.minValue = 0
  $0.maxValue = 100
  $0.step = 10
  $0.cornerRadius = .large
}

API

SliderVM Props

A model that defines the appearance properties for a slider component.

NameTypeDefaultDescription
colorComponentColoraccentThe color of the slider.
cornerRadiusComponentRadiusfullThe corner radius of the slider track and handle.
maxValueCGFloat100The maximum value of the slider.
minValueCGFloat0The minimum value of the slider.
sizeComponentSizemediumThe size of the slider.
stepCGFloat1The step value for the slider.
styleStylelightThe visual style of the slider component.

SUSlider

public init(
  currentValue: Binding<CGFloat>,
  model: SliderVM = .init()
)

UKSlider

Initializers

public init(
  initialValue: CGFloat = 0,
  model: SliderVM = .init(),
  onValueChange: @escaping (CGFloat) -> Void = { _ in }
)

Public Properties

NameTypeDescription
onValueChange(CGFloat) -> VoidA closure that is triggered when the currentValue changes.
modelSliderVMA model that defines the appearance properties.
currentValueCGFloatThe current value of the slider.

Public Subviews

NameTypeDescription
backgroundViewUIViewThe background view of the slider track.
barViewUIViewThe filled portion of the slider track.
stripedLayerCAShapeLayerA shape layer used to render striped styling.
handleViewUIViewThe draggable handle representing the current value.
handleOverlayViewUIViewAn overlay view for handle for the large style.