Split Button

A primary action beside a separately named action-menu button. The primary button reuses QDS native activation and form submission; the secondary button reuses Menu and its top-layer, keyboard and context-independent focus behavior.

Usage

<script type="module" src="/assets/components/split-button/qds-split-button.js"></script>
<qds-split-button id="save" label="Save draft"
  group-label="Opportunity draft actions" menu-label="More draft actions"></qds-split-button>
<script>
  customElements.whenDefined('qds-split-button').then(() => {
    document.querySelector('#save').items = [
      { id: 'review', label: 'Save and request review' },
      { id: 'clear', label: 'Clear draft form' }
    ];
  });
</script>

API

Property / attribute Default Meaning
label empty Visible primary label fallback; the default slot also supports content.
aria-label empty Optional explicit primary action name.
group-label / groupLabel primary label/content Names the action group; generic fallback Split actions.
menu-label / menuLabel More actions Accessible arrow-button/menu name. Use contextual wording when several split actions are present.
items property [] The same copied item/group/separator model as Menu.
variant primary primary, secondary, quiet or destructive.
size md sm, md or lg; both targets remain at least 44px.
disabled false Disables both actions; supports native disabled fieldsets.
loading false Primary busy indicator; disables both actions and closes the menu.
type button Native primary button, submit or reset.
name, value, form empty Primary submitter fields and optional external form owner.
formaction, formenctype, formmethod, formnovalidate, formtarget absent Primary native submitter overrides.

Empty secondary actions disable only the arrow, leaving the primary action available. Updating menu records preserves the menu’s identity/focus rules. Slots: default primary label, icon, suffix. Parts: button, menu-button, group, plus exported menu/item/separator parts. Slotted content stays in place across property changes and reconnects.

Events and native forms

Primary activation emits a cancelable click, then cancelable qds-action with component. Cancel either to prevent its native submit/reset. Secondary actions emit cancelable qds-select with component, id and a copied item; preventing default keeps the menu open. Secondary interactions never emit the primary click/action or submit/reset the form.

The form-associated outer component retains the real form owner. Native validation, submitter name/value and overrides use the shared button engine. click() and focus() address the primary button; showMenu()/hideMenu() address the secondary menu.

Keyboard users Tab between enabled primary and menu buttons. ArrowDown/Up or Enter/Space opens the menu; menu arrows, typeahead, Escape and Tab follow the Menu contract. Both themes, forced colors, focus outlines, loading and disabled states use existing tokens. The native menu is created through the custom-element registry so standalone and catalog imports can be combined safely.

Quangular business use

At /#/investments/pipeline, Quick opportunity draft captures a fictional name and sector. The generated QdsSplitButtonComponent saves a local draft through its primary event or saves and requests review through the secondary menu. Clear draft form preserves saved records. Missing names show validation and focus the field. The visible local draft list shows the result; leaving the screen resets these demonstration records. No backend write or real committee request occurs.