iced-cube

Forms

Select

Chooses one value from a dropdown list.

use iced_cube::select;
API reference
Default: A select with a placeholder until a value is chosen.Default: A select with a placeholder until a value is chosen.
Static preview
Default. A select with a placeholder until a value is chosen.

Usage

Use a select when there are too many options to show as radios, or when space is tight. The list opens below the field, as wide as it, with a check mark on the selected option, and looks like every other menu and list. It closes when an option is chosen, on Escape, or when you click elsewhere; that click goes no further.

Options can be borrowed, such as a const slice, so the list is not copied on every view.

Examples

States

Enum options, with enabled and disabled selects.

States: Enum options, with enabled and disabled selects.States: Enum options, with enabled and disabled selects.
Static preview

API

ItemDescription
select(options, selected)Creates a select over a slice or Vec of options, labelled with their Display text. It renders disabled until it has a message.
.on_select(f) / .on_select_maybe(option)Sets the message emitted with the chosen option. None disables the select.
.placeholder(text)Text shown while nothing is selected.
.width(length)Overrides the width. Defaults to 200 pixels.
select::default_keymap()The default shortcuts as a Keymap<Action>. Bind, unbind or clear chords to change them.
action.apply(&options, selected)The option a resolved Action (Next or Previous) selects, or None at either end. Send it through your on_select message.

Keyboard

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

KeysAction
ArrowDownNext Selects the next option, stopping at the last.
ArrowUpPrevious Selects the previous option, stopping at the first.
Esc