Skip to content

Component Button

MeowLynxSea edited this page Jun 13, 2026 · 5 revisions

Button

A standard clickable button with a caption and optional icon. Headless — visuals come from the registered ButtonRenderer.

Import

use yororen_ui::headless::button::button;

Minimal example

use yororen_ui::headless::button::button;

button("save-btn", cx)
    .caption("Save")
    .on_click(|_, _window, _cx| {
        // handle click
    })
    .render(cx)

Props

Method Purpose
caption(text) Button label.
icon(source) Optional leading IconSource.
icon_size(px) Size of the leading icon.
caption_icon(text, source) Convenience: set both caption and icon in one call.
variant(v) One of the ActionVariantKind values (e.g. Primary, Secondary, Ghost, Danger).
disabled(v) Disable interaction and dim the visuals.
on_click(closure) Fn(&ClickEvent, &mut Window, &mut App) + Send + Sync + 'static.

The standard Div IntoElement chain (.child(...), .flex(), etc.) is the body of the button — not part of the Props table.

Notes

  • Factory takes (id, cx). The id is required for focus tracking.
  • No Entity<ButtonState> — click handling is wired inline via on_click.
  • The on_click closure must be 'static + Send + Sync. Capture self with cx.entity().clone().
  • .render(cx) returns Stateful<Div>.

See also

IconButton, ToggleButton, SplitButton, Form

Clone this wiki locally