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.
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) - Defaults tonil.search_placeholder(:string) - Defaults tonil.search_hint(:string) - Defaults tonil.allow_groups(:boolean) - Defaults tonil.show_checkboxes(:boolean) - 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) - Defaults tonil.Must be one ofnil,"top","center", or"bottom".close_on_select(:boolean) - Defaults tonil.dropdown_min_width(:string) - Defaults tonil.dropdown_max_width(:string) - Defaults tonil.max_height(:string) - Defaults tonil.empty_message(:string) - Defaults tonil.loading_message(:string) - 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) - Defaults tonil.Must be one ofnil,"badges","count","compact","partial", or"none".badges_threshold(:integer) - Defaults tonil.badges_threshold_mode(:string) - Defaults tonil.Must be one ofnil,"count", or"partial".badges_max_visible(:integer) - Defaults tonil.badges_position(:string) - Defaults tonil.Must be one ofnil,"top","bottom","left", or"right".show_counter(:boolean) - Defaults tonil.enable_badge_tooltips(:boolean) - Defaults tonil.badge_tooltip_placement(:string) - 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) - Defaults tonil.badge_tooltip_offset(:integer) - 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) - Defaults tonil.search_input_mode(:string) - Defaults tonil.Must be one ofnil,"normal","readonly", or"hidden".search_mode(:string) - Defaults tonil.Must be one ofnil,"filter", or"navigate".min_search_length(:integer) - Defaults tonil.keep_options_on_search(:boolean) - Defaults tonil.should_keep_search_on_close(:boolean) - Defaults tonil.allow_add_new(:boolean) - 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) - Defaults tonil.actions_layout(:string) - 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) - Defaults tonil.value_member(:string) - Defaults tonil.display_value_member(:string) - Defaults tonil.search_value_member(:string) - Defaults tonil.icon_member(:string) - Defaults tonil.subtitle_member(:string) - Defaults tonil.group_member(:string) - Defaults tonil.disabled_member(:string) - Defaults tonil.value_format(:string) - 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) - Defaults tonil.virtual_scroll_threshold(:integer) - Defaults tonil.option_height(:integer) - Defaults tonil.badge_height(:integer) - Pixel height per badge row in the popover virtual-scroll list. Defaults to36upstream. Defaults tonil.virtual_scroll_buffer(:integer) - Defaults tonil.placeholder(:string) - Placeholder shown when no item is selected (passthrough). Defaults tonil.class(:string) - Defaults tonil.style(:string) - 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.