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.
API reference
public class CheckBox : ComponentBase<CheckBox, HTMLInputElement>, IObservableComponent<bool>, IRoundedStyle, ITextFormatingA two-state form control (checked / unchecked) used for boolean values.
- Namespace
- Tesserae
- Inheritance
- ComponentBase<CheckBox, HTMLInputElement> → CheckBox
- Implements
- IObservableComponent<bool>, IRoundedStyle, ITextFormating
Constructors
| Name | Description |
|---|---|
| CheckBox | Initializes a new instance of this class. |
Properties
| Name | Description |
|---|---|
| Text | Gets or sets button text |
| IsEnabled | Gets or sets whenever CheckBox is enabled |
| IsChecked | Gets or sets whenever CheckBox is checked |
| Size | Gets or sets the text size. |
| Weight | Gets or sets the text weight. |
| TextAlign | Gets or sets the text alignment. |
public bool IsEnabled { get ; set ; }Gets or sets whenever CheckBox is enabled
public bool IsChecked { get ; set ; }Gets or sets whenever CheckBox is checked
Methods
| Name | Description |
|---|---|
| Render | Renders the component's root HTML element. |
| Disabled | Disables the component. |
| Checked | Marks the component as checked. |
| SetText | Sets the text of the component. |
| AsObservable | Returns the component's state as a(n) observable. |
Samples
Basic Usage
The following example demonstrates creating a few CheckBox instances with different configurations: unchecked, checked, disabled, and disabled when checked.