humanonlyweb/ui

Split Button

A main action with a menu of alternatives.

Markdown

Examples

With a menu

Pass the menu's trigger attrs to trigger-attrs.

Copy code

API

PropTypeDefault
menuLabel*

Accessible name for the toggle half, e.g. "More save options".

stringโ€”
triggerAttrs

The attrs from a <Menu> or <Popover> trigger slot, bound to the toggle half.

Record<string, unknown>โ€”
variant

Style hook, exposed as data-button-variant on both halves.

"danger" | "ghost" | "primary" | "secondary" | "solid""secondary"
size

Size hook, exposed as data-button-size on both halves.

"medium" | "small""medium"
disabled

Disables both halves.

booleanfalse
EventPayload
action

The main half was pressed.

[]
toggle

The toggle half was pressed.

[]
SlotProps
default

Main action label.

โ€”
caret

Replaces the toggle's chevron.

{ open: boolean; }

Styling

Parts
split-buttonbutton-label
States
data-split-variantdata-split-partdata-split-open

Accessibility

  • Name the toggle with menu-label.