-
Notifications
You must be signed in to change notification settings - Fork 9
Component SplitButton
MeowLynxSea edited this page Jan 24, 2026
·
4 revisions
A primary action + dropdown options.
SplitButton combines:
- A primary button that runs your main action
- An optional dropdown menu for alternative actions
use gpui::ElementId;
use yororen_ui::component::{split_button, SplitButtonAction};
let view = split_button()
.key(("actions", "export"))
.label("Export")
.option("png", "Export PNG")
.option("pdf", "Export PDF")
.on_primary(|_ev, _window, _cx| {
// ...
})
.on_action(|action, _ev, _window, _cx| {
match action {
SplitButtonAction::Primary => {}
SplitButtonAction::Option(id) => {
// ...
}
}
});- Actions that have a sensible default but also offer variants (export, run, open-with)
-
split_button(): constructor -
id(...) / key(...): stable identity -
label("..."): primary button label -
option(id, label)/options([...]): add dropdown options disabled(bool)-
on_primary(|ev, window, cx| ...): primary click handler -
on_action(|SplitButtonAction, ev, window, cx| ...): unified handler for both primary and options - Styling:
bg/hover_bg/menu_width
- Menu open state is internal (keyed by the element id).
- Clicking outside closes the menu.
- Primary button height:
36px - Menu open state is keyed by the element id; use
key(...)in repeated UIs.
- Use
on_actionif you want a single handler for both primary and menu options.
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.