Skip to content

Slider

extends Element

Slider: value picker (horizontal or vertical); click, drag or scroll.

Properties

PropertyTypeDefaultDescription
minnumber0lowest selectable value
maxnumber100highest selectable value
stepnumber1rounding step for clicks/drags/wheel
valuenumber0current value
horizontalbooleantruefalse = vertical (uses height)
barColornumbercolors.graytrack color
knobColornumbercolors.blueColor of the knob
widthnumber10Width in terminal cells

Events

EventRegistrarDescription
change:onChange(fn)Fired whenever the value changes through user interaction

Methods

Slider:setup()

Initializes per-instance state and input handlers.

Slider:handleMouse(event, btn, x, y)

The mouse wheel adjusts the value by one step.

  • event (string) The mouse event name

  • btn (number) Button or scroll direction

  • x (number) Local x coordinate

  • y (number) Local y coordinate

  • returns consumer (Element|nil) The consuming element, or nil to pass through

Slider:render(buf)

Renders the track and knob (horizontal or vertical).

  • buf (Render) The render buffer

Last updated:

Released under the MIT License.