LavaUI docs GitHub

struct Slider

Swift

struct Slider

A draggable value in a range.

Unlike Button and Toggle, this is a drag control: the press captures the pointer and every move recomputes the value, so the interesting part is coordinate conversion rather than animation. The knob position is not animated at all — during a drag it has to sit under the pointer, and interpolating there reads as the control lagging behind the hand.

No label. A slider's label is not part of its hit target, so it composes better as a neighbouring Text than as a bundled string — which is the opposite of Toggle, where the label is part of what you click.

Sources/LavaUI/Slider.swift:14

Constructors

init(value: Binding<Float>, in range: ClosedRange<Float> = 0...1, step: Float? = nil, format: ((Float) -> String)? = nil, style: SliderStyle = SliderStyle(), font: UIFont? = nil, isEnabled: Bool = true, onEditingChanged: ((Bool) -> Void)? = nil)

Creates a slider. Every parameter matches the property of the same name.

Sources/LavaUI/Slider.swift:39

Properties

var dumpDetail: String { get }

Not documented.

Sources/LavaUI/Slider.swift:62

var font: UIFont?

Font of the readout, or nil for the environment's.

Sources/LavaUI/Slider.swift:26

var format: ((Float) -> String)?

Renders a readout to the right of the track. nil draws no readout.

Sources/LavaUI/Slider.swift:22

var isEnabled: Bool

Whether the slider can be dragged. A disabled slider draws in the style's disabled colours.

Sources/LavaUI/Slider.swift:28

var onEditingChanged: ((Bool) -> Void)?

true when a press starts a drag, false when the button comes up.

For a value that is expensive to apply exactly — a video seek, which decodes from the previous keyframe — and cheap to apply roughly: the caller does the cheap thing for each move and the exact one once, here. true comes before the press's own value, so every value the drag writes — the jump to where it was pressed included — is inside the pair.

Sources/LavaUI/Slider.swift:36

var range: ClosedRange<Float>

The values the track spans, left end to right end.

Sources/LavaUI/Slider.swift:18

var resolvedFont: UIFont? { get }

The readout's font: font, or the environment's when that is nil.

Sources/LavaUI/Slider.swift:60

var step: Float?

Quantisation. nil is continuous.

Sources/LavaUI/Slider.swift:20

var style: SliderStyle

Colours and metrics.

Sources/LavaUI/Slider.swift:24

var value: Binding<Float>

The value the knob shows and dragging writes.

Sources/LavaUI/Slider.swift:16

Methods

func mountPrimitive() -> any AnyViewNode

Not documented.

Sources/LavaUI/Slider.swift:73

func reconcilePrimitive(_ node: any AnyViewNode) -> any AnyViewNode

Not documented.

Sources/LavaUI/Slider.swift:81