Notifications come two ways — bubbling DOM CustomEvents and the matching on* handler properties — plus interceptor callbacks that can veto an
action before it happens.
EV01 Events
Select and deselect options to watch select and change fire.
Each CustomEvent carries detail.option, detail.selectedOptions and detail.selectedValues.
Pick an option to see events appear here…
Breaking change in v2.0.0: the onSelect / onDeselect / onChange handler properties now receive a CustomEvent (read e.detail.*), matching addEventListener — they used to receive the bare option. See the Migration guide.
EV02 beforeSelectCallback veto
Intercept a selection before it happens and cap the picks at three.
Select three items, then try a fourth — the pick is vetoed and a toast appears over the control.
beforeSelectCallbackruns before an option is added.- Return
trueto allow,falseto veto silently. - Returning a string vetoes the selection and surfaces that string
as a transient toast (via the built-in
showMessage), visible even in the fullscreen overlay.
EV03 Add-new creation (v2.0.0)
Turn the picker into a creation tool — type something new and add it on the fly.
Created items log here after the ~800ms delay…
Type a tag that is not listed (e.g. "Frontend"), then click the "Add …" prompt or press Enter.
- New in v2.0.0. With
allow-add-newon, a search with no matches shows an “Add …” prompt (label templated byadd-new-text, where{value}is the typed text). addNewCallbackis async and cancelable: return the created option to add + select it, ornull/undefinedto abort. While it runs, the prompt shows the pending text (add-new-pending-text).- The
addevent fires only when creation actually happens —e.detailcarries the typedvalue, the createdoption, and the updated selection.