Skip to content

CheckBox

A toggleable UI element that can be checked or unchecked. Displays different text based on its state and supports automatic sizing. Commonly used in forms and settings interfaces for boolean options.

Extends: VisualElement

Usage

lua
-- Create a checkbox for a setting
local checkbox = parent:addCheckBox()
:setText("Enable Feature")
:setCheckedText("✓")
:onChange("checked", function(self, checked)
-- React to checkbox state changes
if checked then
-- Handle enabled state
else
-- Handle disabled state
end
end)

Properties

PropertyTypeDefaultDescription
checkedbooleanfalseThe current state of the checkbox (true=checked, false=unchecked)
textstringemptyText shown when the checkbox is unchecked
checkedTextstringxText shown when the checkbox is checked
autoSizebooleantrueAutomatically adjusts width based on text length

Released under the MIT License.