Skip to content

Split Button

Keep one primary action visible beside a consumer-owned dropdown of related actions. Menu items support captions, leading and trailing icons, native links, new-tab metadata, HTMX, and local handlers.

Default Rendered example
Usage Example
@splitbutton.SplitButton(splitbutton.Config{
    Primary: splitbutton.Action{Label: "Publish", Href: "/publish"},
    MenuLabel: "More publish actions",
    Sections: []dropdown.Section{
        {Items: []dropdown.Item{
            {Label: "Preview", Caption: "Review the draft", Href: "/preview"},
            {Label: "Open docs", Caption: "View in a new tab", Href: "/docs", Target: "_blank", Rel: "noopener noreferrer", TrailingIcon: externalIcon()},
            {Label: "Schedule", OnClick: "schedule()"},
        }},
    },
})

Consumer-owned trigger and items

The primitive composes Dropdown; the consumer still decides the label, icon, destinations, captions, and behavior for every action.

Consumer-owned trigger and items Rendered example

Last action:

Consumer-owned trigger and items
@splitbutton.SplitButton(splitbutton.Config{
    Primary: splitbutton.Action{Label: "Save", OnClick: "save()"},
    MenuTriggerIcon: moreIcon(),
    Sections: []dropdown.Section{
        {Items: []dropdown.Item{
            {Label: "Duplicate", OnClick: "duplicate()"},
            {Label: "Delete", Danger: true, Caption: "Cannot be undone", OnClick: "remove()"},
        }},
    },
})

Go API

v0.2.7

The examples above cover behavior and composition. pkg.go.dev is the canonical reference for exported types, functions, methods, and Go documentation.

github.com/araihu/goshtoso/components/splitbutton
Open v0.2.7 API