Builds an H3UI button whose label reflects a boolean value. value defaults to false; labels default to On and Off.
Example
local enabled = true
local status = ui.text {
text = 'Enabled',
}
ui.column {
children = {
ui.toggle {
label = 'Sound',
value = enabled,
onChange = function(value)
enabled = value
status.props.text = value and 'Enabled' or 'Disabled'
end,
},
status,
},
}Parameters
| Field | Type | Description |
|---|---|---|
value | boolean? | Initial state; defaults to false. |
onChange | function? | Receives the new boolean value. |
label | string | Base label for the control. |
onLabel | string? | Label suffix for the enabled state. |
offLabel | string? | Label suffix for the disabled state. |
labelProps | table? | Properties for the generated label. |
template | openmw.ui.Template? | Replaces the default H3UI button template. |
Common layout fields are documented on the UI Components overview. onChange runs after the label changes.
See also
button · slider · collapsible