Fully customize options, badges, and selected items using render callbacks with HTML or DOM elements
.options and render callbacks assigned via a small
page script after the custom element upgrades.
These examples demonstrate renderOptionContentCallback
for customizing how options appear in the dropdown.
getBadgeClassCallback
for dynamic price-based badge colors (Budget: green, Mid-Range: blue, Premium: pink).
Price badges in dropdown options also color-coded based on price ranges.
These examples demonstrate renderBadgeContentCallback
for customizing selected item badges.
These examples demonstrate renderSelectedContentCallback
for customizing the selected value text in single-select mode.
Examples demonstrating how to combine multiple rendering callbacks for sophisticated customization.
These examples show how renderOptionContentCallback
and renderBadgeContentCallback
work together to create different displays for the same data in different contexts (dropdown vs badges vs popover).
renderOptionContentCallback
(rich dropdown with status, priority, tags),
renderBadgeContentCallback
(compact "▶️ Name" in main area, detailed "▶️ Name [priority]" in popover using context.isInPopover),
and getBadgeDisplayCallback
(plain text "Name - status (priority)" for tooltips).
renderBadgeContentCallback
for compact badge display and renderSelectedItemContentCallback
for detailed popover display.
Uses getBadgeClassCallback
to add priority-based CSS classes (badge-urgent, badge-important, badge-normal, badge-low).
Uses customStylesCallback
to inject CSS into Shadow DOM for styling those classes.
Demonstrates separate callbacks for badges vs. selected items popover and solving Shadow DOM CSS isolation.
Examples demonstrating flex/grid layouts with checkbox alignment control.