Skip to content
S3ctor’s S3cret St4sh
api

slider

Build a bounded pointer-controlled numeric slider.

Builds a meter-based horizontal track. Pointer presses and drags map to min..max, clamp to the range, and optionally round to step.

Example

local util = require 'openmw.util'

local value = 50
local readout = ui.text {
  text = '50%',
}

ui.column {
  children = {
    ui.slider {
      value = value,
      min = 0,
      max = 100,
      step = 5,
      props = {
        size = util.vector2(240, 18),
      },
      onChange = function(nextValue)
        value = nextValue
        readout.props.text = tostring(nextValue) .. '%'
      end,
    },
    readout,
  },
}

Parameters

FieldTypeDescription
valuenumber?Initial value; defaults to min.
minnumber?Lower bound; defaults to 0.
maxnumber?Upper bound; defaults to 1.
stepnumber?Optional rounding increment.
trackWidthnumber?Rendered width for relative tracks.
fillPropstable?Properties for the filled portion.
emptyPropstable?Properties for the empty portion.
onChangefunction?Receives the normalized value.
templateopenmw.ui.Template?Replaces the default H3UI meter template.

Common layout fields are documented on the UI Components overview. Invalid ranges and non-positive steps raise an error during construction.

See also

meter · numberInput · selector