Skip to content

PixelUI.Toggle

Extends: PixelUI.Widget

A toggle switch widget with on/off states and customizable appearance. Features a sliding thumb animation and optional labels.

Properties

NameTypeDescription
valuebooleanCurrent toggle state (true = on, false = off)
labelOnstringLabel text when toggle is on
labelOffstringLabel text when toggle is off
trackColorOnPixelUI.ColorTrack color when on
trackColorOffPixelUI.ColorTrack color when off
trackColorDisabledPixelUI.ColorTrack color when disabled
thumbColorPixelUI.ColorColor of the sliding thumb
knobColorDisabledPixelUI.ColorThumb color when disabled
onLabelColorPixelUI.Color?Text color for "on" label
offLabelColorPixelUI.Color?Text color for "off" label
focusBgPixelUI.Color?Background color when focused
focusFgPixelUI.Color?Foreground color when focused
focusOutlinePixelUI.Color?Outline color when focused
showLabelbooleanWhether to show the label text
disabledbooleanWhether the toggle is disabled
knobMarginintegerHorizontal inner margin for the knob travel
knobWidthinteger?Optional fixed knob width
transitionDurationnumberSeconds for knob transition animation
transitionEasingfun(t:number):numberEasing function for knob transition
private_thumbProgress
private_animationHandle
onChangefun(self:PixelUI.Toggle,

Methods

new

lua
new()

_cancelAnimation

lua
_cancelAnimation()

_setThumbProgress

lua
_setThumbProgress()

_animateThumb

lua
_animateThumb()

_emitChange

lua
_emitChange()

setOnChange

lua
setOnChange()

setValue

lua
setValue()

isOn

lua
isOn()

toggle

lua
toggle()

setLabels

lua
setLabels()

setShowLabel

lua
setShowLabel()

setDisabled

lua
setDisabled()

isDisabled

lua
isDisabled()

setColors

lua
setColors()

setTransition

lua
setTransition()

setKnobStyle

lua
setKnobStyle()

draw

lua
draw()

handleEvent

lua
handleEvent()

Released under the MIT License.