-
Notifications
You must be signed in to change notification settings - Fork 9
Component Button
MeowLynxSea edited this page Feb 12, 2026
·
5 revisions
A clickable action.
Button is the standard “action” primitive. It is a styled container that you can put any child
content into (text, icons, custom layout).
use yororen_ui::component::button;
let save = button()
.child("Save")
.on_click(|_ev, _window, _cx| {
// ...
});- Primary/secondary actions in forms, toolbars, dialogs
- Menu rows (when you want full-width clickable rows)
Not a good fit:
- Pure icon actions (use
IconButton)
-
button(): constructor -
id(...) / key(...): stable identity (optional, only needed for state management) -
clickable(bool): whether it should respond to clicks (default:true) -
disabled(bool): disable interaction + apply disabled styles -
variant(ActionVariantKind): theme variant (Neutral/Primary/Danger) -
on_click(|ev, window, cx| ...): click handler -
on_hover(|active, window, cx| ...): hover handler -
bg(Hsla)/hover_bg(Hsla): override background colors
- Height:
36px - Padding: horizontal
px_4, verticalpy_2 - Corner radius:
rounded_md
-
disabled(true)prevents click handlers from running. - If you render many buttons at the same call site (lists) and need state tracking, provide a stable
id(...)(or render them underVirtualRow, which provides per-row namespacing).
use yororen_ui::component::button;
use yororen_ui::theme::ActionVariantKind;
let primary = button().variant(ActionVariantKind::Primary).child("Save");
let disabled = button().variant(ActionVariantKind::Danger).disabled(true).child("Delete");- Prefer
key(...)only when you render many stateful buttons in repeated/virtualized UIs.
Yororen UI v0.3.0 · repository · Apache-2.0 · This wiki documents Yororen UI v0.3.0.
This wiki documents Yororen UI v0.3.0 — the headless-core, swappable-renderer build.