Skip to main content

Module widgets

Module widgets 

Source
Expand description

egui’s small widgets drawn through the kit (docs/kit.md): a checkbox, a radio button, a selectable row, a toggle chip, and the arrow of a combo box; and an on/off Switch, which egui lacks.

Each keeps egui’s layout (egui’s atoms, sizes and spacing), its interaction and what it tells assistive technology; the kit paints the box (the checkbox, radio, selectable-row, toggle-chip and combo-arrow components) and the marks are glyph roles (check, indeterminate, radio, dropdown). A role’s default icon is drawn with egui’s own geometry, so the default kit looks like egui; a kit naming another icon gets that icon. They replace egui’s own:

eguiegui-pop
ui.checkbox(&mut on, text)checkbox(ui, &mut on, text), or Checkbox
ui.radio(on, text)radio(ui, on, text), or RadioButton
ui.radio_value(&mut v, x, text)radio_value(ui, &mut v, x, text)
ui.selectable_label(on, text)selectable_label(ui, on, text), or SelectableRow
ui.selectable_value(&mut v, x, text)selectable_value(ui, &mut v, x, text)
ComboBox::from_id_salt(id)combo_box(id)
ComboBox::new(id, label)combo_box_labelled(id, label)
a selectable label used as a toggleToggleChip
a checkbox drawn as a switch (egui’s demo toggle_switch)switch(ui, &mut on, text), or Switch

Splitter has no counterpart in egui, whose panels keep their resize lines to themselves and out of the keyboard’s reach. SortHeader, a column’s header, has none either. Nor has Segmented, a row of exclusive options (a view’s modes, a tab strip), which replaces a row of selectable_value buttons.

A combo box’s own box stays egui’s: it follows button through egui’s Visuals (theme::visuals_with); only its arrow is the kit’s.

Re-exports§

pub use crate::segmented::SegmentOption;
pub use crate::segmented::SegmentOverflow;
pub use crate::segmented::Segmented;
pub use crate::segmented::segment_fit;
pub use crate::segmented::segment_step;

Structs§

Checkbox
A checkbox: its box is the kit’s checkbox component (selected while checked), its mark the check glyph (indeterminate when so shown), in the state’s text, its label in the text of the same state unchecked. egui’s [egui::Checkbox], drawn through the kit.
RadioButton
A radio button: its circle is the kit’s radio component (selected while chosen), its mark the radio glyph in the state’s text, its label in the text of the same state unchosen. egui’s [egui::RadioButton], drawn through the kit.
SelectableRow
A row picked from a short list: its box is the kit’s selectable-row component, selected for the chosen one (never hover then, so the choice stays visible under the pointer), its label in the state’s text. egui’s ui.selectable_label (a selectable [egui::Button]), drawn through the kit, with egui’s padding and height.
SortHeader
A column’s header: its box is the kit’s table-header-cell component, selected while the rows are sorted by it, the direction the kit’s sort-ascending or sort-descending glyph after the title. A button for assistive technology, a label when it does not sort. The data table’s and the file picker’s.
Splitter
The line between two panes side by side, in the room given to it: a width in value, changed by a drag, the left and right arrows while it has the keyboard (with Shift, by bigger steps), and given back to its default by a double click or Enter.
Switch
An on/off switch: a track (the kit’s switch component, selected while on) and a round thumb, at the track’s start while off and at its end while on, in the state’s text; its label after it, in the text of the same state off. Laid out as a checkbox is (egui’s interaction height, the box’s side as the track’s height), clicked, or pressed with Space or Enter when focused, to toggle. A switch to assistive technology (AccessKit’s Switch role, toggled while on), named by its label or by Switch::name. The thumb moves at once: no animation to wait for, none to turn off for reduced motion.
ToggleChip
A small toggle showing a short text or a glyph, on while selected: its box is the kit’s toggle-chip component (based on selectable-row), its text or glyph in the state’s text. It is a checkbox for assistive technology, named by ToggleChip::name (else its text). The find bar’s case, whole word and regular expression options.

Functions§

bar_text_button
A frameless text button sized for a bar: small text, no box, as wide as its text, egui’s hover look (its text brightens under the pointer) and the focus ring when it has the keyboard. A breadcrumb’s step, a profile’s name in a title bar, a job’s line in a status bar: a click target that must not look like a button among the bar’s text.
checkbox
A checkbox (Checkbox): ui.checkbox, drawn through the kit.
combo_box
egui’s [ComboBox] with the kit’s arrow (paint_combo_arrow): ComboBox::from_id_salt.
combo_box_labelled
egui’s [ComboBox] with a label and the kit’s arrow: ComboBox::new.
paint_combo_arrow
Paints a combo box’s arrow ([ComboBox::icon]): the kit’s combo-arrow box over rect, selected while the list is open, then the dropdown glyph in its text (the default icon with egui’s own geometry, a triangle as wide as egui’s).
radio
A radio button (RadioButton): ui.radio, drawn through the kit.
radio_value
A radio button setting current to alternative when clicked: ui.radio_value, drawn through the kit.
selectable_label
A selectable row (SelectableRow): ui.selectable_label, drawn through the kit.
selectable_value
A selectable row setting current to value when clicked: ui.selectable_value, drawn through the kit.
switch
A switch (Switch): an on/off toggle with a track and a thumb.