CheckBox
Description
The CheckBox component is a UI element used for binary selection, allowing users to toggle between two states: checked and unchecked. It provides a simple, clickable interface with an associated label, making it ideal for scenarios where a user chooses one or more items or settings (e.g., "Remember me" options or multi-selection lists).
Usage
Instantiate a CheckBox component using the static helper method from Tesserae.UI. In the sample below, a basic CheckBox is created, with fluent methods to set text, checked state, and disabled state.
Methods
Disabled(bool value = true)
Disables (or enables) the CheckBox component.
Parameters:
• value (bool, optional): When true, disables the component; when false, enables it.Checked(bool value = true)
Sets the checked state of the CheckBox.
Parameters:
• value (bool, optional): When true, marks the CheckBox as checked; when false, leaves it unchecked.SetText(string text)
Sets the text label for the CheckBox.
Parameters:
• text (string): The label text to be displayed alongside the CheckBox.AsObservable()
Returns an observable for the CheckBox’s state, allowing subscription to changes.
Returns:
• IObservable: Observable that emits the CheckBox's checked state whenever it changes.
Properties
Text
Gets or sets the label text of the CheckBox.
Type: stringIsEnabled
Gets or sets whether the CheckBox is enabled. This property inversely reflects the disabled state.
Type: boolIsChecked
Gets or sets whether the CheckBox is checked.
Type: bool
Samples
Basic Usage
The following example demonstrates creating a few CheckBox instances with different configurations: unchecked, checked, disabled, and disabled when checked.