actionButtons is an array you assign on the element. Each entry is select-all, clear-all, or custom β€” the built-ins wire their own behaviour, while custom buttons run your onClick(ms).

AB01 Built-in + custom actions

Select all and Clear come wired; a custom button selects the first three.

Controls
Quick usage
 
  • Built-ins auto-disable smartly: Select all disables once every option is selected, Clear disables while nothing is selected β€” no callback needed.
  • The action bar is laid out with attributes: actions-position, actions-align and actions-layout (try the controls).
  • Custom buttons receive the live element as ms; here ms.setSelected(values, { notify: true }) fires change.

AB02 Dynamic buttons

Text, visibility and disabled state driven by callbacks that re-evaluate on every selection change.

Open the dropdown and select items: the Clear button appears with a live count, and Select all disables once everything is picked.

Quick usage
 
  • getTextCallback(ms) β€” compute the label (here a live selected count).
  • getIsVisibleCallback(ms) β€” show/hide the button (Clear only appears when something is selected).
  • getIsDisabledCallback(ms) β€” enable/disable reactively (Select all off at max).
  • getClassCallback(ms) β€” swap CSS classes by state (inject the styles via customStylesCallback, since the button lives in the shadow root).
  • Callbacks always win over the matching static property (text, cssClass, …).
Dynamic actionButtons
 

AB03 The standardized action context (v2.2.0)

Callbacks now get a typed ActionContext β€” live state + a controller facade β€” as their 2nd argument.

Open the dropdown and select items: the first button’s label tracks selectedCount / optionCount and its click toasts via ctx.controller; β€œInvert” flips the selection using ctx.options + ctx.selectedValues.

Quick usage
 
  • v2.2.0 hands every action-button callback a typed ActionContext<T> as an additive 2nd argument β€” onClick, getTextCallback, getIsVisibleCallback, getIsDisabledCallback, getClassCallback and getTooltipCallback. Existing one-argument (ms) => … code is unaffected.
  • It's a snapshot of live state β€” selectedCount, optionCount, selectedValues, selectedOptions, options, searchTerm, isOpen β€” plus ctx.controller, a MultiSelectController facade that mirrors the element API (setSelected, showMessage, open/close, search, …).
  • It extends PresentationContext, so a button can branch on ctx.isFullscreen / ctx.isModal β€” the same contract the render callbacks use. ActionContext and MultiSelectController are exported from the package entry.
Reading the ActionContext