Callbacks are assigned as JS properties (they can't be HTML attributes). The rendering callbacks may return raw HTML β€” read Security.

Data extraction

Callback counterparts to the *-member attributes β€” use for computed values.

CallbackTypeDescription
getValueCallback (item) => string | numberCompute the value/id.
getDisplayValueCallback (item) => stringCompute the label.
getSearchValueCallback (item) => stringCompute the searchable text.
getIconCallback (item) => stringCompute the icon.
getSubtitleCallback (item) => stringCompute the subtitle.
getGroupCallback (item) => stringCompute the group name.
getDisabledCallback (item) => booleanCompute disabled state.
getFullTitleCallback (item) => stringCompute the full/long title.
getBadgeDisplayCallback (item) => stringCompute badge text (separate from the label).
getPathCallback v2.0.0 (item) => stringCompute a node’s materialized tree path (counterpart to path-member; enables tree mode).
getIsSelectableCallback v2.0.0 (node) => booleanTree only. Whether a node is selectable β€” receives the built node, so it can read node.hasChildren (e.g. leaves-only). Counterpart to is-selectable-member.

Tooltips & formatting

Property-only callbacks for tooltip content and value formatting.

CallbackTypeDescription
getOptionTooltipCallback (item) => string | HTMLElementTooltip content for an option row (default: label + subtitle). Requires enable-option-tooltips.
getBadgeTooltipCallback (item) => string | HTMLElementTooltip content for a badge. Requires enable-badge-tooltips.
getRemoveButtonTooltipCallback (item) => stringTooltip text (title attribute) for a badge’s remove (Γ—) button.
getValueFormatCallback (values) => stringSerialize the selected values for the hidden form input (overrides value-format).

Rendering (may emit raw HTML)

These receive a presentation-aware context (isFullscreen, tree metadata) in v2.0.0.

CallbackTypeDescription
renderOptionContentCallback (item, ctx) => string | HTMLElementCustom option-row content.
renderBadgeContentCallback (item, ctx) => string | HTMLElementCustom content inside the built-in badge pill.
renderBadgeCallback v2.0.0 (item, ctx) => string | HTMLElement | nullOwn the whole badge markup. Return null to fall back to the default pill; use data-action="remove" for the remove control.
renderSelectedItemContentCallback (item) => string | HTMLElementCustom selected item in the popover.
renderSelectedContentCallback (item) => stringCustom single-select display.
renderGroupLabelContentCallback (groupName) => string | HTMLElementCustom group header.
getBadgeClassCallback (item) => string | string[]Extra CSS classes for badges.
getSelectedItemClassCallback (item) => string | string[]Extra CSS classes for popover items.
customStylesCallback () => stringInject a CSS string into the shadow root.

Search & selection hooks

CallbackTypeDescription
searchCallback (term, signal?) => Promise<T[]>Async search. Wire the AbortSignal into fetch to cancel.
beforeSearchCallback (term) => string | nullPre-process the term; return null to veto.
beforeSelectCallback (option, selected) => boolean | string | voidVeto a selection (false), or veto + toast (string).
beforeDeselectCallback (option, selected) => boolean | string | voidVeto a deselection (false), or veto + toast (string).
onSelect / onDeselect / onChange (e: CustomEvent) => voidFire-and-forget handlers. v2.0.0: now receive a CustomEvent, not a bare option.
getCounterCallback (count, moreCount?) => stringFormat the selected-count label (i18n / pluralization).
keydownCallback v2.0.0 (ctx) => boolean | voidIntercept keydown before built-in handling; return true to suppress. ctx.controller exposes focus/select helpers.

Add-new creation (v2.0.0)

CallbackTypeDescription
addNewCallback v2.0.0 (value) => T | null | Promise<T | null>Create a new option from the typed text (async & cancelable; return null/undefined to abort). The returned option flows through the get*/render* callbacks.
getAddNewTextCallback v2.0.0 (value) => stringCompute the add-new prompt label (plain text). Takes precedence over add-new-text.
onAddNew v2.0.0 (detail) => voidFires when the user commits creation.

Example

Assigning callbacks