Skip to main content
Version: v2.4.0 (Current)

🔘 Checkbox

The Checkbox widget is a dual-state input used to toggle settings on or off. It consists of a clickable box (the indicator) and a text label, making it the standard choice for configuration menus and preference lists.


⚙️ Properties (Props)

The Checkbox configuration is defined by the CheckboxWidget interface. It combines a boolean state with a descriptive string.

PropertyTypeDescription
CheckedbooleanThe current state of the widget (On/Off).
TextstringThe label displayed next to the checkbox.
X / YnumberThe coordinate position on the canvas.

🎨 Visual Parts

In the Style Panel, you can customize the different components of the Checkbox:

  • Main: Styles the background and layout of the entire widget area.
  • Indicator: Styles the box itself. You can change the border color, background color, and the "check" mark appearance for both the checked and unchecked states.
  • Label: Styles the text typography, color, and spacing relative to the box.

🛠 Interaction Logic

The Checkbox is designed to be user-friendly on touchscreens:

  • Hitbox: Clicking anywhere on the text label or the box will toggle the state.
  • Feedback: The indicator visually transitions between states instantly, providing immediate confirmation to the user.

⚡ Runtime API (Lua)

Use the Logic and Events system to react to state changes or to set the checkbox programmatically based on system data.

-- Check if a setting is enabled
if cb_wifi:get_state() then
print("WiFi is enabled")
end

-- Programmatically check the box
cb_notifications:set_state(true)

-- Update the label text dynamically
cb_status:set_text("System Active")

DESIGN BEST PRACTICE

For binary choices where the action takes effect immediately (like "Airplane Mode"), consider using a Switch. Use a Checkbox for settings that are part of a larger form or require a "Save/Apply" action.


🚀 Next Steps

  • Switch — A modern alternative for toggling system states.
  • Button — Use if you need a momentary action rather than a persistent state.
  • Logic and Events — Learn how to save checkbox states to non-volatile memory.