The render callbacks return raw HTML (or a DOM element) so you can build rich option rows,
restyle badges, or replace a whole pill with a card. They are set imperatively on the element
in setup(el), never as attributes. To restyle the shadow-DOM internals themselves without any JavaScript, reach for the custom-styles attribute
(v2.2.0) โ see CR03 below.
CR01 Rich option rows
renderOptionContentCallback builds a multi-line row with icon, label, and subtitle.
Open the dropdown โ each row renders your HTML instead of the plain label.
renderOptionContentCallbackreceives(item, ctx)and returns the row's inner HTML.- In v2.0.0 the
ctxis presentation-aware (ctx.isFullscreen), so you can render leaner rows on phones where the dropdown goes fullscreen.
CR02 Whole-badge rendering (v2.0.0)
renderBadgeCallback replaces the entire pill โ here a Bootstrap badge with its own remove button.
Select a few countries โ each selection becomes a fully custom badge you own.
renderBadgeCallbackis new in v2.0.0 and owns the whole badge, not just its content. Returnnullto fall back to the default pill for an item.- Any element inside your badge with
data-action="remove"triggers deselect โ the component wires it up for you, no event handlers required. renderBadgeContentCallbackis the lighter alternative when you only want to change the content inside the built-in pill.
CR03 Declarative styling โ custom-styles (v2.2.0)
Style the shadow-DOM internals with a plain attribute โ zero JavaScript.
Select a few items โ the badges are pill-shaped and the option hover is tinted, all from the custom-styles attribute above.
custom-stylestakes raw CSS as a string and injects it verbatim โ selectors and all โ into a replaceable style slot at the top of the shadow root, the same slotcustomStylesCallbackuses.- Because it's an attribute, static HTML, server-rendered markup, and no-build pages can restyle
internals like
.ms__badgeand.ms__option(and your own custom-rendered content) with no script at all. It's reactive and mirrored by thecustomStylesproperty. - When both are set,
customStylesCallbackwins โ treat the attribute as the static fallback.