Skip to content

Component Button

MeowLynxSea edited this page Jun 18, 2026 · 5 revisions

Button

A clickable button with a caption and optional icon.

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

button("save", cx)
    .caption("Save")
    .on_click(|_, _, _| { /* handle click */ })
    .render(cx)

Props

Method Purpose
caption(text) Button label.
icon(source) Optional leading IconSource.
icon_size(px) Size of the leading icon (default 16).
caption_icon(text, source) Convenience: set both caption and icon.
variant(v) ActionVariantKind::Neutral (default) / Primary / Danger.
disabled(v) Disable interaction and dim visuals.
on_click(closure) Fn(&ClickEvent, &mut Window, &mut App) + 'static + Send + Sync.

Factory takes (id, cx). .render(cx) returns Stateful<Div>. No state entity. Add body content via .child(...) on the returned div if you didn't pass a caption.

See also: IconButton, ToggleButton, SplitButton.

Clone this wiki locally