Skip to content

Split Button

Primary action button paired with a lightweight dropdown of secondary actions.

Live Preview
import '@bnotk/dsx/components/split-button.js';
<dsx-split-button label="Save" variant="primary">
<dsx-split-option value="draft">Save draft</dsx-split-option>
<dsx-split-option value="copy">Save as copy</dsx-split-option>
</dsx-split-button>

Main split-button wrapper with a primary button, a toggle button, and a dropdown menu.

PropertyTypeDefaultDescription
labelstringText label for the primary action button.
variant’primary’ | ‘secondary''primary’Switches between filled and outlined visual treatments.
disabledbooleanfalseDisables both button segments and closes pointer interaction.

None.

EventDetailDescription
dsx-clickBubbles/composed when the primary action button is clicked.
dsx-option-select{ value: string | null }Bubbles/composed when a dsx-split-option is chosen.
SlotDescription
defaultOne or more <dsx-split-option> children rendered inside the dropdown menu.

This element does not expose shadow parts.

  • Opening the dropdown attaches a one-shot document click listener after the current task so outside clicks close the menu.
  • The default slot has a click handler that resolves the nearest dsx-split-option with closest().

Simple block option used inside the split button dropdown.

PropertyTypeDefaultDescription
valuestringValue returned in the dsx-option-select event detail.

None.

None.

SlotDescription
defaultVisible option label/content.

This element does not expose shadow parts.

  • The option itself does not dispatch events; the parent split button handles selection.
  • The host is inline-flex and position: relative so the dropdown can be absolutely positioned to the right edge.
  • Primary and toggle segments share a border radius split across left/right corners.
  • The toggle button exposes aria-haspopup="true" and mirrors the _open state through aria-expanded.
  • Primary variant uses --ds2-color-main / --ds2-color-main-dark with white text.
  • Secondary variant uses white background, inset border, and the main color for text and separator.
  • Dropdown surface uses --ds2-color-white, --ds2-color-grey-2, and --ds2-shadow-md.