Skip to main content

Toggle Control State (ui_element.toggle)

This function is available in versions after 20260507

Declaration

ok, info_or_err = ui_element.toggle(selector_or_element [, options ])

Parameters

  • selector_or_element Table. A selector, an element returned by a query, or a coordinate table { x = X, y = Y }.
  • options Optional, table. See Common options.

Returns

  • ok Boolean. true on success, nil on failure.
  • info_or_err Table on success, string failure reason on failure.

Description

Toggle a switch, checkbox, or another control whose confirmed state can be read. If the target state cannot be read, this API may return nil, "state unavailable".

Example

local ui_element = require("ui_element")

ui_element.toggle({
title = "Airplane Mode",
role = "switch",
})