iced-cube

Forms

Checkbox

Turns an option on or off, with an indeterminate state for mixed selections.

use iced_cube::checkbox;
use iced_cube::primitives::checkbox::CheckState;
API reference
States: Unchecked, checked and indeterminate, enabled and disabled.States: Unchecked, checked and indeterminate, enabled and disabled.
Static preview
States. Unchecked, checked and indeterminate, enabled and disabled.

Usage

Use a checkbox for independent options that take effect when a form is submitted. For a setting that applies straight away, a switch reads better.

The indeterminate state is for a parent box whose children are partly selected. The app works out the parent’s state from its children, as the select-all example shows, and a click on an indeterminate box always checks it.

Examples

Default

A labelled checkbox bound to a bool.

Default: A labelled checkbox bound to a bool.Default: A labelled checkbox bound to a bool.
Static preview

Select all

A parent checkbox that turns indeterminate for a mixed selection.

Select all: A parent checkbox that turns indeterminate for a mixed selection.Select all: A parent checkbox that turns indeterminate for a mixed selection.
Static preview

API

ItemDescription
checkbox(state)Creates a checkbox from a bool or a CheckState. It renders disabled until it has a message.
.label(text)Adds a label after the box. Clicking the label toggles the checkbox too.
.on_toggle(f) / .on_toggle_maybe(option)Sets the message for a click. The closure gets the new checked value, so an indeterminate box reports true. None disables the checkbox.
CheckStateUnchecked, Checked or Indeterminate. toggled() gives the state after a click.
checkbox::default_keymap()The default shortcuts as a Keymap<Action>, for apps that track a current checkbox.
Action::Toggle.apply(state)The checked value a click would send. Pass it to your on_toggle message.

Keyboard

Default shortcuts. Every one can be changed or removed with a keymap; see Keyboard shortcuts.

KeysAction
SpaceToggle Checks or unchecks the current checkbox. An indeterminate box becomes checked.
Esc