Slider
The draggable value: track, brand fill, a ringed thumb.
Value is a fraction in [0, 1] — map it to your domain at the call
site. Press or drag anywhere on the control; Step snaps to multiples.
Installation
Use the module import (the default), or own the source: lotusui add
vendors the component into your app and lotusui update keeps the copy mergeable —
see Registry.
go get github.com/ikaito-com/lotusui
# or vendor the source into your app:
go run github.com/ikaito-com/lotusui/cmd/lotusui add slider
Usage
var volume = lotusui.Slider{Value: 0.4}
volume.Layout(th, gtx)
percent := volume.Value * 100
Step
quarters := lotusui.Slider{Step: 0.25}
Disabled
s.Disabled = true
Range
Values with two entries — two thumbs, the fill between them; each stays between its neighbors.
s := lotusui.Slider{Values: []float32{0.25, 0.5}, Step: 0.05}
Multiple
Any number of entries — one thumb each.
s := lotusui.Slider{Values: []float32{0.1, 0.2, 0.7}, Step: 0.1}
Vertical
Vertical rotates the axis; cap the height at the call site — the value grows upward.
s := lotusui.Slider{Value: 0.5, Vertical: true}
gtx.Constraints.Max.Y = gtx.Dp(160)
s.Layout(th, gtx)
API
| Option | Type | Description |
|---|---|---|
Value | float32 | Fraction in [0, 1] — map to your domain at the call site. |
Values | []float32 | Multi-thumb mode: one thumb per entry, kept ordered; two = range. |
Step | float32 | Snaps to multiples; zero = continuous. |
Vertical | bool | Rotates the axis; the value grows upward. |
Disabled | bool | Dimmed, inert. |