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.
- 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-alignandactions-layout(try the controls). - Custom buttons receive the live element as
ms; herems.setSelected(values, { notify: true })fireschange.
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.
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 viacustomStylesCallback, since the button lives in the shadow root).- Callbacks always win over the matching static property (
text,cssClass, β¦).
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.
- v2.2.0 hands every action-button callback a typed
ActionContext<T>as an additive 2nd argument βonClick,getTextCallback,getIsVisibleCallback,getIsDisabledCallback,getClassCallbackandgetTooltipCallback. Existing one-argument(ms) => β¦code is unaffected. - It's a snapshot of live state β
selectedCount,optionCount,selectedValues,selectedOptions,options,searchTerm,isOpenβ plusctx.controller, aMultiSelectControllerfacade that mirrors the element API (setSelected,showMessage,open/close,search, β¦). - It extends
PresentationContext, so a button can branch onctx.isFullscreen/ctx.isModalβ the same contract the render callbacks use.ActionContextandMultiSelectControllerare exported from the package entry.