Skip to content
Focsd homeFocsd homeFocsd
Forms

Split button

A main action joined to a menu of related actions.

  • Tag: focsd-split-button
  • Pattern: Group: button + menu button (Menu Button)
  • Category: Actions

Example

Save as draft Save as template Archive
HTML
<focsd-split-button label="Save" variant="action">
<focsd-menu-item value="draft">Save as draft</focsd-menu-item>
<focsd-menu-item value="template">Save as template</focsd-menu-item>
<focsd-menu-item value="archive" disabled>Archive</focsd-menu-item>
</focsd-split-button>

Usage

Import the module once, then use the tag like any HTML element. Every framework below renders the same element; see Frameworks for setup.

<script type="module">
import '@focsd-dev/components/focsd-split-button.js';
</script>
<focsd-split-button label="Save" variant="action">…</focsd-split-button>

API

Attributes

AttributePropertyTypeDefault
labellabelstring—
openopenbooleanfalse
variantvariant'plain' | 'action' | 'quiet' | 'critical'plain
disableddisabledbooleanfalse

Methods

MethodDescription
openMenu(edge)Open and focus the first or last item.
closeMenu()Close the menu.

Slots

SlotDescription
(default)The focsd-menu-item elements.
triggerThe button that opens the menu.

CSS parts

Style the inside of the component with ::part(), for example focsd-split-button::part(group).

PartDescription
groupThe group around both buttons.
mainThe primary action button (a `focsd-button`).
menu-buttonThe button that opens the menu.
menuThe menu element.

Accessibility

  • Both buttons sit in a group named by label. The main button reads the label; the menu button is named "More actions for {label}" ("More actions" when there is no label) and has aria-haspopup="menu" and aria-expanded.
  • The menu is a role=menu of focsd-menu-item children with the same keyboard as focsd-menu. Disabled items are skipped by the arrow keys and cannot be chosen.
  • Escape, or choosing an item, closes the menu and returns focus to the menu button.
  • The host click event comes only from the main button; clicks on the menu button and in the menu stop inside the element. Choosing an item fires focsd-select (detail.value, detail.item).
  • disabled turns off both buttons.

Keyboard

KeyAction
Enter / Space / DownOn the menu button: open the menu on the first item
UpOn the menu button: open the menu on the last item
Down / UpMove between items
Enter / SpaceChoose the focused item
EscapeClose the menu and return to the menu button