zaxis 0.1.0
Components

Components

Constructors, convenience methods, bound values, and shared response behavior.

Import components from zaxis or zaxis::components. zaxis::widgets remains a compatibility re-export of the component module.

ComponentShort formUse
WindowWindow::new(title).show(context, build)Retained panel with drag and resize
ScrollAreaScrollArea::vertical().show(ui, build)Measured viewport, nested scrolling and virtual rows
Gridui.grid(id, columns, build)Shared column widths and arbitrary cell layouts
TableTable::new(id).columns(columns).show(ui, build)Pinned headers, resize, selection, sort requests and virtual rows
CollapsingHeaderui.collapsing(id, caption, body)Measured disclosure and independent header actions
DockDock::new(id, &mut state).show(ui, viewer)IDE panel groups, splitting, floating windows and a sliding focus ring
TreeViewui.tree(id, &model)Stable hierarchical model, keyboard navigation and virtual rows
Drag and dropui.drag_source(id, payload, build) / ui.drop_target(id, accept, build)Typed in-window drag, drop targets, preview and autoscroll
PopupPopup::new(id, anchor).show(ui, &mut open, build)Overlay layer, viewport placement and dismissal
ModalModal::new(id).show(ui, &mut open, build) / Dialog / ConfirmInput-blocking dialogs, confirmations and sheets
ComboBoxui.combo_box(&mut Option<T>, &options) / ui.combo_box_values(&mut T, pairs)Stable selection and optional filtering
MenuBarui.menu_bar(id, &items)Menu bar or compact menu with cascading submenus
Toastcontext.toast(Toast::new(title).content(text))Passive transient notifications
KeyBoxui.key_box(&mut KeyBinding, label)Captures the next key or mouse button
IconTabsui.icon_tabs(&mut value, tabs)Vertical icon strip bound to a selection
ListBoxListBox::new(id).show_rows(ui, len, entry, content)Virtualized list on stable keys: single/multiple/checked selection, type-ahead, sections, measured rows
CarouselCarousel::new(id).pages(n).show(ui, &mut page, content)Stack of cards or photo slider: swipe with fling and rubber band, keys, wheel, buttons, indicators, autoplay
SegmentedControlui.segmented(&mut value, options)Sliding-thumb or Material 3 style single choice row
Badgeui.add(Badge::new(text))Passive chip for key caps, pills and counts
Textui.label(text)Read-only text
Iconsui.image(&icons::USER)Bundled Lucide icons, tintable (bundled-icons feature)
Hyperlinkui.hyperlink_to(text, url)Links, links inside styled text, selectable and copyable static text
TextEditui.text_edit(&mut String)Single-line Unicode editing and IME
FocusGroupFocusGroup::new(id).show(ui, build)One Tab stop and arrow-key navigation for several controls; a toolbar is built from it
Buttonui.button(text)Activation
Checkboxui.checkbox(&mut bool, text)Boolean value
Switchui.switch(&mut bool, text)Animated on/off value
NumberInput / DragValueui.number_input(&mut value) / ui.drag_value(&mut value)Typed numeric value
Sliderui.slider(&mut number, range)Numeric value, floats and integers
ColorPickerui.color_picker(&mut Color, text)HSV, RGB, and HEX color selection
CardCard::new(id).show(ui, build)Framed, padded container
FieldField::new(label).validation(v).show(ui, build)Label, control and validation message with steady layout
Separatorui.separator()Passive dividing line

Builders are consumed when shown or added. Use ui.add(Component::new(...).builder(...)) for options unavailable in the short form. Window, ScrollArea, Grid and Table are containers with show, not implementations of Widget.

use zaxis::{Button, Slider};

ui.add(Button::new("Run").enabled(can_run).tooltip("Run the selected task"));
ui.add(Slider::new(&mut gain, 0.0..=1.0).step(0.05).width(240.0));
ui.add(Slider::new(&mut volume, 0..=100).suffix("%")); // integers: step 1, no decimals
ui.heading("Output");

One rule for enabled and disabled

  • One control: .enabled(bool) on its builder, the same on every control (Button, Checkbox, Switch, Slider, TextEdit, NumberInput, DragValue, ComboBox, ColorPicker, headers, trees, drag sources and targets).
  • A group: ui.add_enabled_ui(bool, build).

The deprecated spellings disabled(bool), Ui::add_enabled, button_enabled, checkbox_enabled, switch_enabled and slider_enabled still work and mean exactly the replacements above. The other shared builder names are the same everywhere too: id_source(impl Hash), width(f32), style(..), hover_style(HoverStyle), corner_radius(impl Into<CornerRadius>) (the old rounding is a deprecated alias) and status(SemanticStatus). Out-of-range arguments are normalized, never panics; see Diagnostics.

For dependent controls, keep short forms inside an enabled group:

ui.add_enabled_ui(notifications, |ui| {
    ui.checkbox(&mut sound, "Play sound");
    ui.add(Slider::new(&mut volume, 0..=100).text("Volume").suffix("%").enabled(sound));
});
ui.tab_bar(&mut section, [(0, "General"), (1, "Appearance")]);
ui.selectable_value(&mut accent_blue, true, "Blue");
ui.selectable_value(&mut accent_blue, false, "Green");
ui.muted("Changes are stored in memory.");

Enabled state composes with each widget's own enabled setting. A nested group cannot re-enable a disabled parent. Layout and bound values are preserved; disabled controls cannot activate, focus, or capture the pointer. Custom widgets can query Ui::is_enabled() to follow the same contract.

selectable returns activation only; selectable_value and tab_bar also report changed() when selection changes. Tabs use values as IDs, so values must be unique within a bar. They use ordinary button Tab/Enter/Space navigation.

Tabs share the row equally. A label wider than its share gets its natural width, and when the natural widths no longer fit the row, the strip becomes a horizontal ScrollArea (wheel, touchpad, overlay thumb); clicking a tab scrolls it into view.

Ui::add returns Response and requests follow-up repaint on a click, value change, text submission or text focus loss. Use clicked() for activation and changed() for bound-value updates. Exact response semantics and keyboard controls are in Input and responses.

To add a new passive component using the public API, use Custom components.

Edit on GitHub

On this page