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.
| Component | Short form | Use |
|---|---|---|
| Window | Window::new(title).show(context, build) | Retained panel with drag and resize |
| ScrollArea | ScrollArea::vertical().show(ui, build) | Measured viewport, nested scrolling and virtual rows |
| Grid | ui.grid(id, columns, build) | Shared column widths and arbitrary cell layouts |
| Table | Table::new(id).columns(columns).show(ui, build) | Pinned headers, resize, selection, sort requests and virtual rows |
| CollapsingHeader | ui.collapsing(id, caption, body) | Measured disclosure and independent header actions |
| Dock | Dock::new(id, &mut state).show(ui, viewer) | IDE panel groups, splitting, floating windows and a sliding focus ring |
| TreeView | ui.tree(id, &model) | Stable hierarchical model, keyboard navigation and virtual rows |
| Drag and drop | ui.drag_source(id, payload, build) / ui.drop_target(id, accept, build) | Typed in-window drag, drop targets, preview and autoscroll |
| Popup | Popup::new(id, anchor).show(ui, &mut open, build) | Overlay layer, viewport placement and dismissal |
| Modal | Modal::new(id).show(ui, &mut open, build) / Dialog / Confirm | Input-blocking dialogs, confirmations and sheets |
| ComboBox | ui.combo_box(&mut Option<T>, &options) / ui.combo_box_values(&mut T, pairs) | Stable selection and optional filtering |
| MenuBar | ui.menu_bar(id, &items) | Menu bar or compact menu with cascading submenus |
| Toast | context.toast(Toast::new(title).content(text)) | Passive transient notifications |
| KeyBox | ui.key_box(&mut KeyBinding, label) | Captures the next key or mouse button |
| IconTabs | ui.icon_tabs(&mut value, tabs) | Vertical icon strip bound to a selection |
| ListBox | ListBox::new(id).show_rows(ui, len, entry, content) | Virtualized list on stable keys: single/multiple/checked selection, type-ahead, sections, measured rows |
| Carousel | Carousel::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 |
| SegmentedControl | ui.segmented(&mut value, options) | Sliding-thumb or Material 3 style single choice row |
| Badge | ui.add(Badge::new(text)) | Passive chip for key caps, pills and counts |
| Text | ui.label(text) | Read-only text |
| Icons | ui.image(&icons::USER) | Bundled Lucide icons, tintable (bundled-icons feature) |
| Hyperlink | ui.hyperlink_to(text, url) | Links, links inside styled text, selectable and copyable static text |
| TextEdit | ui.text_edit(&mut String) | Single-line Unicode editing and IME |
| FocusGroup | FocusGroup::new(id).show(ui, build) | One Tab stop and arrow-key navigation for several controls; a toolbar is built from it |
| Button | ui.button(text) | Activation |
| Checkbox | ui.checkbox(&mut bool, text) | Boolean value |
| Switch | ui.switch(&mut bool, text) | Animated on/off value |
| NumberInput / DragValue | ui.number_input(&mut value) / ui.drag_value(&mut value) | Typed numeric value |
| Slider | ui.slider(&mut number, range) | Numeric value, floats and integers |
| ColorPicker | ui.color_picker(&mut Color, text) | HSV, RGB, and HEX color selection |
| Card | Card::new(id).show(ui, build) | Framed, padded container |
| Field | Field::new(label).validation(v).show(ui, build) | Label, control and validation message with steady layout |
| Separator | ui.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.