Phoenix function component wrapping <web-multiselect>.
Summary
Functions
Renders a <web-multiselect> custom element.
Functions
@spec web_multiselect(map()) :: Phoenix.LiveView.Rendered.t()
Renders a <web-multiselect> custom element.
Examples
<.web_multiselect
id="languages"
placeholder="Pick a language"
options={[%{value: "js", label: "JavaScript"}, %{value: "py", label: "Python"}]} />
<.web_multiselect field={@form[:tags]} options={@tag_options} />LiveView events
When hook={true} is set (see the README), the underlying select, deselect, and
change events are forwarded to the server. Listen for them with handle_event/3:
def handle_event("web_multiselect:change", %{"id" => id, "values" => values}, socket) do
...
endTo push option or selection changes back from the server, use
Keenmate.WebMultiselect.push_update/3.
Attribute defaults
Every attribute defaults to nil, which means "don't emit it" — the underlying
component's own default then applies. The docs below note the upstream default where
it's useful to know. See the upstream usage docs
for the full behavior of each option.
Attributes
id(:string) - DOM id; required when used with a LV hook. Defaults tonil.field(Phoenix.HTML.FormField) - APhoenix.HTML.FormFieldto bind to. Defaults tonil.name(:string) - Form field name (overridden by:fieldif set). Defaults tonil.value(:any) - Initial selected value(s). Strings, numbers, list, or nil. Defaults tonil.options(:any) - Option list. Accepts:- a list of maps with
:value/:label(and optional:icon,:subtitle,:group,:disabled) - a list of
{value, label}tuples - a list of arbitrary maps when paired with
*_memberorget_*_callbackprops (JS side)
Defaults to
nil.- a list of maps with
hook(:any) - Forwardsselect/deselect/changeevents to LiveView. Passhook={true}for the bundled"KeenWebMultiselectHook", or a string to name a custom hook.falseornilrenders no hook. Requires:id.Defaults to
nil.search_event(:string) - Server-side search hook. When set, the LV hook installs asearchCallbackon the element that pushes this event name to the LV with%{"query" => q, "id" => id}and awaits a{:reply, %{results: [...]}, socket}response. The results populate the dropdown asynchronously. Requireshook={true}.Defaults to
nil.multiple(:boolean) - Allow selecting more than one option. Defaults totrueupstream — setfalsefor a single-select. Defaults tonil.search_placeholder(:string) - Placeholder text for the search/filter input inside the dropdown. Defaults tonil.search_hint(:string) - Hint line shown near the search input to guide the user (e.g. "Type to filter…"). Defaults tonil.allow_groups(:boolean) - Render options grouped by theirgroup_member(optgroup-style headers). Off by default. Defaults tonil.show_checkboxes(:boolean) - Render a checkbox in each option row. Off by default. Defaults tonil.show_select_all(:boolean) - Shows upstream's built-in "Select All" action button above the option list (internal:isSelectAllShown). Pairs naturally withshow_checkboxes. For finer control over the button row use theaction_buttonsAPI instead.Defaults to
nil.checkbox_align(:string) - Vertical alignment of each option's checkbox within its row. Defaults tonil. Must be one ofnil,"top","center", or"bottom".close_on_select(:boolean) - Close the dropdown after a selection is made (typical for single-select). Defaults tonil.dropdown_min_width(:string) - Minimum width of the dropdown panel, as a CSS length (e.g."320px"). Defaults tonil.dropdown_max_width(:string) - Maximum width of the dropdown panel, as a CSS length. Defaults tonil.max_height(:string) - Maximum height of the option list before it scrolls, as a CSS length. Defaults tonil.empty_message(:string) - Message shown when there are no options to display. Defaults tonil.loading_message(:string) - Message shown while async options are loading. Defaults tonil.select_placeholder(:string) - Placeholder shown when the input isn't a usable search box (enable_search={false}, orsearch_input_modeis"readonly"/"hidden"). Defaults to"Pick an option..."upstream — set this to override.Defaults to
nil.no_data_placeholder(:string) - Placeholder shown when the option list is empty. Useful for cascade multiselects whose parent isn't resolved yet. Takes priority overplaceholderandsearch_placeholderwhen the list is empty. Unset by default so async-loaded selects don't flash an empty-state message before their data arrives.Defaults to
nil.badges_display_mode(:string) - How selected items appear in the control:badges(default),count,compact,partial, ornone. Defaults tonil. Must be one ofnil,"badges","count","compact","partial", or"none".badges_threshold(:integer) - Selected-count at which the display collapses to thebadges_threshold_modesummary. Defaults tonil.badges_threshold_mode(:string) - How to summarize oncebadges_thresholdis exceeded —countorpartial. Defaults tonil. Must be one ofnil,"count", or"partial".badges_max_visible(:integer) - Maximum number of badges rendered before the remainder collapse into a summary. Defaults tonil.badges_position(:string) - Where the badges render relative to the input. Defaults tonil. Must be one ofnil,"top","bottom","left", or"right".show_counter(:boolean) - Show a count of the selected items. Defaults tonil.enable_badge_tooltips(:boolean) - Show a tooltip with the full label when hovering a badge. Off by default. Defaults tonil.badge_tooltip_placement(:string) - Placement of the badge tooltip (a Floating-UI placement). Defaults tonil. Must be one ofnil,"top","top-start","top-end","bottom","bottom-start","bottom-end","left","left-start","left-end","right","right-start", or"right-end".badge_tooltip_delay(:integer) - Show/hide delay for badge tooltips, in milliseconds. Defaults tonil.badge_tooltip_offset(:integer) - Distance of the badge tooltip from the badge, in pixels. Defaults tonil.remove_button_tooltip_text(:string) - Format string for the remove-button tooltip.{0}interpolates the item name. Defaults to"Remove {0}"upstream. Defaults tonil.enable_option_tooltips(:boolean) - Show a hover tooltip on each dropdown option row. Default content is the option's display value, plus its subtitle on a second line when present. Override per option with the JS-sidegetOptionTooltipCallback. Off by default upstream.Defaults to
nil.option_tooltip_placement(:string) - Placement relative to the option row. Defaults to"top-start"upstream (anchored to the row's start edge). Useleft/rightfor a narrow control's side. Defaults tonil. Must be one ofnil,"top","top-start","top-end","bottom","bottom-start","bottom-end","left","left-start","left-end","right","right-start", or"right-end".option_tooltip_follow_cursor(:boolean) - Anchor the option tooltip to the mouse pointer and follow it across the row. Useful for very wide rows. Defaults tofalseupstream. Defaults tonil.option_tooltip_delay(:integer) - Show/hide delay in ms. Falls back tobadge_tooltip_delay, then100upstream. Defaults tonil.option_tooltip_offset(:integer) - Tooltip offset in px from the row. Falls back tobadge_tooltip_offset, then8upstream. Defaults tonil.enable_search(:boolean) - Show the search/filter input inside the dropdown. On by default upstream. Defaults tonil.search_input_mode(:string) - Search input behavior:normal,readonly, orhidden. When not usable,select_placeholdershows. Defaults tonil. Must be one ofnil,"normal","readonly", or"hidden".search_mode(:string) - What typing does:filternarrows the list,navigatejumps to matching rows without hiding others. Defaults tonil. Must be one ofnil,"filter", or"navigate".min_search_length(:integer) - Minimum number of characters before searching/filtering kicks in. Defaults tonil.keep_options_on_search(:boolean) - Keep the full option list visible while searching instead of filtering it down. Defaults tonil.should_keep_search_on_close(:boolean) - Preserve the search text when the dropdown closes instead of clearing it. Defaults tonil.allow_add_new(:boolean) - Allow creating a new option from the search text when nothing matches. Defaults tonil.search_debounce(:integer) - Debounce delay in milliseconds before the asyncsearchCallbackfires. A burst of keystrokes collapses into a single request instead of one per character. Applies to the async path only — local in-memory filtering stays instant. Defaults to0(no debounce) upstream.Defaults to
nil.sticky_actions(:boolean) - Keep the action-buttons row pinned while the option list scrolls. Defaults tonil.actions_layout(:string) - Whether action buttons stay on a single row (nowrap) or wrap onto multiple rows (wrap). Defaults tonil. Must be one ofnil,"nowrap", or"wrap".actions_position(:string) - Render the action-buttons block as a sticky header ("top", default) or footer ("bottom"). Defaults tonil. Must be one ofnil,"top", or"bottom".actions_align(:string) - Horizontal arrangement of buttons within a row."stretch"(default) keeps full-width; the others size buttons to content and distribute them. Defaults tonil. Must be one ofnil,"stretch","left","right","center", or"space-between".lock_placement(:boolean) - Lock the dropdown's placement instead of auto-flipping/shifting to fit the viewport. Defaults tonil.value_member(:string) - Object key to read each option's value from. The wrapper defaults this to"value". Defaults tonil.display_value_member(:string) - Object key for each option's display label. The wrapper defaults this to"label". Defaults tonil.search_value_member(:string) - Object key for the text search matches against. Not defaulted — falls back to the display value upstream. Defaults tonil.icon_member(:string) - Object key for an option's icon. The wrapper defaults this to"icon". Defaults tonil.subtitle_member(:string) - Object key for an option's secondary line. The wrapper defaults this to"subtitle". Defaults tonil.group_member(:string) - Object key for an option's group name (used whenallow_groups). The wrapper defaults this to"group". Defaults tonil.disabled_member(:string) - Object key marking an option disabled. The wrapper defaults this to"disabled". Defaults tonil.value_format(:string) - How selected values are serialized into the hidden form input:json,csv, orarray. Defaults tonil. Must be one ofnil,"json","csv", or"array".initial_values(:any) - Pre-selected values. List/term; encoded as JSON for the underlying attribute. Defaults tonil.enable_virtual_scroll(:boolean) - Enable windowed rendering of the option list so large datasets stay fast. Defaults tonil.virtual_scroll_threshold(:integer) - Option count above which virtual scrolling activates automatically. Defaults tonil.option_height(:integer) - Fixed pixel height of each option row — required for the virtual-scroll offset math. Defaults tonil.badge_height(:integer) - Pixel height per badge row in the popover virtual-scroll list. Defaults to36upstream. Defaults tonil.virtual_scroll_buffer(:integer) - Extra rows rendered above and below the viewport while virtual-scrolling. Defaults tonil.placeholder(:string) - Placeholder shown when no item is selected (passthrough). Defaults tonil.class(:string) - CSS class(es) applied to the<web-multiselect>element. Defaults tonil.style(:string) - Inlinestyleapplied to the<web-multiselect>element. Defaults tonil.show_debug_info(:boolean) - Toggles upstream's.ms__debug-infostats panel inside the shadow DOM. Reactive — flipping between renders adds/removes the panel without reinitializing the component. Useful while diagnosing virtual-scroll thresholds, search timing, and option-list growth.Defaults to
nil.Global attributes are accepted. Any extra HTML / phx-* attribute; passed through verbatim.
Slots
inner_block- Optional declarative<option>/<optgroup>markup.