Elements
Checkbox
A toggle input element for boolean values. Wraps Unity's Toggle with shadcn-inspired styling — a clean bordered box that fills dark with a white checkmark when checked.
Constructor
new Checkbox();
new Checkbox(reactiveProperty); // Bound to ReactiveProperty<bool>Examples
Two-Way ReactiveProperty Binding
Checkboxes provide automatic two-way binding with ReactiveProperty:
// Constructor binding (preferred)
new Checkbox(AcceptTerms)
.Label("I accept the terms and conditions");
// Explicit binding
new Checkbox()
.BindValue(AcceptTerms)
.Label("I accept the terms and conditions");
// When user toggles, AcceptTerms.Value updates automatically
// When AcceptTerms.Value changes, the checkbox updatesForm Fields
Common form field patterns:
// Simple toggle
new Checkbox(RememberMe)
.Label("Remember me");
// Disabled checkbox
new Checkbox(LockedOption)
.Label("Premium feature")
.Disabled(true);
// Checkbox without label
new Checkbox(IsEnabled);Reactive State Management
Checkboxes can respond to state:
// Conditionally disabled based on other state
new Checkbox(AcceptTerms)
.Label("I accept the terms")
.BindDisabled(IsSubmitting);
// Dynamic label
new Checkbox(DarkMode)
.BindLabel(DarkMode.Select(on =>
on ? "Dark mode (on)" : "Dark mode (off)"));Change Callbacks
React to value changes without binding:
new Checkbox()
.Label("Enable notifications")
.OnChange(enabled => Debug.Log($"Notifications: {enabled}"));Properties
| Prop | Type | Default |
|---|---|---|
value? | bool | false |
label? | string | "" |
disabled? | bool | false |
visible? | bool | true |
name? | string | "" |
pickingMode? | PickingMode | PickingMode.Position |
Methods
| Prop | Type | Default |
|---|---|---|
Value? | (bool) => Checkbox | - |
GetValue? | () => bool | - |
BindValue? | (ReactiveProperty<bool>) => Checkbox | - |
Label? | (string) => Checkbox | - |
GetLabel? | () => string | - |
BindLabel? | (Observable<string>) => Checkbox | - |
OnChange? | (Action<bool>) => Checkbox | - |
Disabled? | (bool = true) => Checkbox | - |
GetDisabled? | () => bool | - |
BindDisabled? | (Observable<bool>) => Checkbox | - |
Visible? | (bool) => Checkbox | - |
GetVisible? | () => bool | - |
BindVisible? | (Observable<bool>) => Checkbox | - |
ClassName? | (string, bool = true) => Checkbox | - |
BindClassName? | (string, Observable<bool>) => Checkbox | - |
StyleSheet? | (StyleSheet) => Checkbox or (string) => Checkbox | - |
Checkbox extends BaseElement.