Skip to content

Component SplitButton

MeowLynxSea edited this page Jun 18, 2026 · 4 revisions

SplitButton

A primary action button with a chevron that opens a dropdown of secondary actions.

use yororen_ui::headless::dropdown_menu::{DropdownMenuItem, DropdownMenuState};
use yororen_ui::headless::split_button::split_button;

let menu_state = DropdownMenuState::new(&mut **cx);

split_button("run", |_, _, _| { /* primary action */ }, cx)
    .caption("Run")
    .items(vec![
        DropdownMenuItem::new("run-debug", "Run with debugger"),
        DropdownMenuItem::new("run-profile", "Run with profiler"),
    ])
    .state(menu_state)
    .on_select({
        let entity = cx.entity();
        move |id, _, cx| entity.update(cx, |s, _| s.last_action = id.to_string());
    })
    .render(cx)

Props

Method Purpose
caption(text) Primary label.
items(v) Vec<DropdownMenuItem> shown in the dropdown half.
state(s) Entity<DropdownMenuState> (caller-owned).
on_select(closure) Fn(SharedString, &mut Window, &mut App) + 'static + Send + Sync.
disabled(v) Disable both halves.

Factory takes (id, primary_click, cx) where primary_click is Fn(&ClickEvent, &mut Window, &mut App) + 'static + Send + Sync. .render(cx) returns Stateful<Div>.

See also: Button, DropdownMenu.

Clone this wiki locally