Checkbox

Checkbox is a check box with its label beside it, for lists of independent yes/no choices such as what to include in an export.

Last updated

On this page

A check box with its label to the right. It holds the same kind of value as a Toggle, drawn differently: use check boxes for lists of independent yes/no choices, a toggle for settings.

Checkbox.builder("includeKeys")
        .label(Text.translatable("mymod.includeKeys", "Include key bindings"))
        .value(() -> export.includeKeys)
        .onChange(checked -> export.includeKeys = checked)
        .build();

Builder#

Method Required Default Notes
label(Supplier<Text>) / label(Text) yes the text to the right of the box
value(BooleanSupplier) yes whether it is checked; re-read on every refresh
onChange(Consumer<Boolean>) yes stores the new state; main thread
enabled, tooltip, visible no options every widget has

Behaviour#

Test it#

host.click("includeKeys");

Rendered as [checkbox includeKeys] [x] Include key bindings, or [ ] while unchecked.

See also#