zaxis 0.1.0
Components

Button

Activation, builders, identity, sizing, and disabled behavior.

if ui.button("Run").clicked() {
    runs += 1;
}

Builders

use zaxis::{vec2, Border, Button, Color, CornerRadius, Padding};

let response = ui.add(Button::new("Apply")
    .id_source("apply")
    .enabled(dirty)
    .min_size(vec2(96.0, 38.0))
    .padding(Padding::symmetric(14.0, 8.0))
    .corner_radius(CornerRadius::all(4.0))
    .border(Border::new(1.0, Color::gray(100))));
MethodDefault / behavior
new(text)Caption as Into<String>; hidden ##suffix contributes to ID
id_source(impl Hash)Override caption-based identity within the UI scope
enabled(bool)true
min_size(Vec2)(0, 0) preferred minimum
padding(Padding)Style::button_padding
rounding(CornerRadius)Radius 5 on all corners; independent of Style::rounding
corner_radius(f32 or CornerRadius)Same override, with scalar shorthand
variant(ButtonVariant)Surface; Solid (accent fill), Soft (translucent tint), Outline, Ghost, Glass (see Glass). Explicit style, border and rounding still win
glass(f32)Glass look at a strength in 0..=1 on any variant, 0 opts out of a glass theme. It blurs the backdrop unless blur is set
selected(bool)false; selected buttons keep the pressed fill
icon(impl Into<ImageSource>)A leading icon one line tall, tinted like the caption (for example &icons::CHEVRON_DOWN with bundled-icons); it widens the button and moves with align, hover, pressed and disabled looks
border(Border)Style::border; visible keyboard focus takes precedence
hover_style(HoverStyle)Theme hover preset; supports fill, shadow, gradient and custom combinations

Variants only change colors: layout, input and focus behavior are identical. Use Solid for the single primary action in a view and Ghost for dense toolbars.

The desired size is text size plus padding, enlarged to min_size and at least 24 × 24. Allocated width is limited by available layout width, even when that width is smaller than the preferred minimum. Captions do not wrap; their paint is clipped inside button padding.

Activation

Press and release the primary pointer over the same button, or focus it and release Enter/Space. clicked() is true during the following UI pass. changed() remains false because a button has no bound value.

Disabled buttons block pointer fallthrough, cannot receive keyboard focus, and do not activate. Their fill uses Style::button_fill and their caption uses Style::muted_text. Hover uses the hover preset; pressing uses Style::button_pressed. Keyboard focus uses Style::focus_border instead of the builder border; there is no extra outer ring. Validation status still adds its soft ring.

Use IDs and retained state for dynamic captions and repeated buttons.

Accessibility

Role Button, named by its label. A toggle button also publishes its toggled state. A Click request acts like a pointer click. A button without text (an icon, a ##id label) needs .accessible_label(".."); without it a MissingAccessibleName diagnostic is reported while a screen reader is connected. See Accessibility.

Edit on GitHub

On this page