AROYN UI LIBRARY / UI COMPONENTS

Toggle

Store a boolean preference with smooth track and thumb feedback.

Create Toggle#

Store a boolean preference with smooth track and thumb feedback.

The constructor returns a Toggle handle. The snippet assumes section exists, as created in Quick start.

LUAU
local toggle = section:CreateToggle({
    Name = "Show details", Flag = "details", Default = false,
    Callback = function(value) print("Details:", value) end,
})

Arguments#

OptionTypeDefaultMeaning
DefaultbooleanfalseInitial normalized value.
Callbackfunction(boolean)nilReceives the changed value.

Also accepts common options: Name, Description, Disabled and Callback; stateful controls additionally support Flag, Persist and Sensitive.

Manage state#

LUAU
toggle:SetValue(true)       -- silent
toggle:SetValue(false, true) -- notify
print(toggle:GetValue())

Returned methods#

MethodReturnsBehavior
GetValue()booleanCurrent boolean value.
SetValue(value, notify?)selfSilent by default; true calls Callback only after a changed normalized value.
SetDisabled(boolean)selfChanges user availability without discarding the value.
IsDisabled()booleanReads the requested disabled state.
Destroy()nilRemoves this control and its subscriptions; safe to repeat.

Behavior and limitations#

Default and SetValue require booleans. Construction does not invoke Callback.

Loading a saved true preference does not start an application feature by itself. Keep runtime activation explicit.