Skip to main content

Slider

Properties

PropertyTypeDescription
minnumberSliders minimum value
maxnumberSliders maximum value
defaultValuenumber, arraySliders default value
disabledbooleanWeather slider is disabled for use
tooltipOpenboolean, nilHow the tooltip should be handled
tooltipPlacementSee TooltipPlacementHow the tooltip should be handled
stepnumberHow big steps the slider takes
verticalbooleanWeather slider should be vertical
autoFocussbooleanWhen true slider will be focused when mounted
keyboardbooleanWhen true slider can be moved with keyboard
dotsboolean"Whether the thumb can drag over tick only"
rangebooleanWhen true the slider has 2 thumbs
reversebooleanWhen true the slider is reversed
[events]functionPlease read the events page

All properties are optional.

See more properties here

Children

Not supported on slider.

Example

local slider = myUI:createElement("Slider", {
width = "200px",
min = 0,
max = 500,
defaultValue = 100,
step = 5.0,
onAfterChange = function(elementId, uiName, value)
print("onAfterChange: ", elementId, uiName, value)
end,
onChange = function(elementId, uiName, value)
print("onChange: ", elementId, uiName, value)
end,
})

This is how it looks in-game:

In Game

Min

The minumum value the slider can be set to.

Min

Max

The maximum value the slider can be set to.

Max

Default Value

The value the slider will start with.

In the showcased example the starting value is 100.

When range is true the defaultValue should be an array, like:

defaultValue = {25, 75}

Disabled

When true the slider will be disabled.

Which means the user will not be able to move the slider.

Disabled

TooltipOpen

When undefined/nil the tooltip will show when the user is interacting with the slider.

When true the tooltip will always show.

When false the tooltip will never show.

TooltipOpen

TooltipPlacement

Sets the direction of the tooltip.

It's a string and can be any of the following:

top, left, right, bottom, topLeft, topRight, bottomLeft, bottomRight, leftTop, leftBottom, rightTop, rightBottom

TooltipPlacement

Step

Sets the amount the slider "steps" with each time.

This is how it looks with a step equal to 0.5

Step

Vertical

When true the slider will be displayed vertically instead of horizontally

Vertical

Auto Focus

When true the slider will be focused when the UI is shown.

Keyboard

When true the slider can be controlled with the keyboard aswell as the mouse.

Dots

I'm not actually sure what this does.

The Ant Design description is "Whether the thumb can drag over tick only".

Range

When true the slider will have 2 end and both can be moved.

Note value in onAfterChange and onChange is now an array.

local slider = myUI:createElement("Slider", {
width = "200px",
min = 0,
max = 100,
defaultValue = {25, 75},
onAfterChange = function(id, name, value)
local min = value[1]
local max = value[2]
print("Min: " .. min .. " - Max: " .. max)
end,
})

Range

Reverse

Flips/Reverses the slider.

Reverse