Checkbox
An 18 px square with a check when on, or a dash when indeterminate, and an optional label beside it. The whole row takes the press, so the label is as much a target as the square.



Fixtures: checkbox-default, checkbox-disabled and checkbox-indeterminate.
Build
public static BibuiWidget Checkbox(
this BibuiRuntime runtime,
string id,
bool on,
ReadOnlySpan<char> label = default,
bool disabled = false,
bool indeterminate = false)| Parameter | Meaning |
|---|---|
id | The row's retained box. |
on | Draws the check. The checkbox never writes it. |
label | Text to the right of the square. |
disabled | A disabled edge and label. Swallows the press and reports nothing. |
indeterminate | Draws a dash instead of the check, and takes precedence over on. Use it for a "select all" over a partly selected list. |
Claims and reports
- The row claims
InteractionKinds.LeftPress, orDisabled. - It returns a
BibuiWidgetwhoseNodeis the row. Flip your value onClicked.
State the caller owns
on, and whether the box is indeterminate.
Theme tokens
- Square:
Accentfill and edge when on or indeterminate. Otherwise aSurfacefill and aBorderedge. The edge isTextDisabledwhen disabled. - Check and dash:
AccentForeground. - Label:
TextColor.Primary, orTextColor.Disabled. - The edge is
runtime.Theme.Borders.Widthwide.
Example
using Bibui.Core;
using Bibui.Core.Runtime;
sealed class NotificationSettings
{
const string All = "All notifications";
const string Email = "Email";
const string Push = "Push";
bool _email = true, _push; // the caller's state
public UiNode Build(BibuiRuntime runtime)
{
var column = runtime.BeginParent(runtime.Column());
// "All" is indeterminate while only some are on, and turns them all on or off.
bool some = _email != _push;
if (runtime.Checkbox("notify-all", _email && _push, All, indeterminate: some).Clicked)
_email = _push = !(_email && _push);
runtime.Gap(12f);
if (runtime.Checkbox("notify-email", _email, Email).Clicked) _email = !_email;
runtime.Gap(12f);
if (runtime.Checkbox("notify-push", _push, Push).Clicked) _push = !_push;
runtime.EndParent(column);
return column;
}
}