Skip to content

Toggle

A Toggle lets people choose between a pair of opposing states, like on and off, using a different appearance to indicate each state.

Component preview

Summary

Properties

Property Type Description
Value boolean? The toggle's state. false for off, true for on

View all inherited from BaseComponent

View all inherited from CanvasGroup

Methods

View all inherited from CanvasGroup

Events

Event Signature Description
ValueChanged ((self: Toggle, value: boolean) -> unknown)? A callback function that is triggered when the Value property has been modified.

View all inherited from CanvasGroup

Types

type ToggleProperties = CanvasGroup & {
    Value: boolean?,
    ValueChanged: ((self: Toggle, value: boolean) -> unknown)?,
}

type Toggle = BaseComponent & Components & ToggleProperties

Function Signature

function(self, properties: ToggleProperties): Toggle

Example

local toggle = row:Right():Toggle({
    Value = true,
    ValueChanged = function(self, value: boolean)
        print("Value changed:", value)
    end,
})

print(toggle:IsA("CanvasGroup")) --> true
print(toggle.ClassName) --> "CanvasGroup"
print(toggle.Type) --> "Toggle"