Liking cljdoc? Tell your friends :D

x-multi-combobox

A multi-select combobox with type-ahead filtering. Selected items display as removable chips. Options are provided as <option> children; selected options are hidden from the dropdown and reappear when deselected.

Tag name

<x-multi-combobox>...</x-multi-combobox>

Observed attributes

AttributeTypeDefaultDescription
valuestring""Comma-separated selected values
placeholderstring""Input placeholder (shown when no chips)
namestring""Form field name
disabledbooleanfalseDisables the component
requiredbooleanfalseMarks as required
openbooleanfalseControls panel visibility
placementenum"bottom-start"Panel position relative to input
maxnumbernoneMaximum number of selections

Placement values

bottom-start | bottom-end | top-start | top-end

Properties

PropertyTypeReflected attributeNotes
valuestring[]valueGetter returns JS array; setter accepts array or CSV string
placeholderstringplaceholder
namestringname
disabledbooleandisabled
requiredbooleanrequired
openbooleanopen
placementstringplacement
maxnumbermax

Public methods

MethodDescription
show()Opens the dropdown panel (source: "programmatic")
hide()Closes the dropdown panel (source: "programmatic")

Events

x-multi-combobox-change-request

Fired before a value is added or removed. Cancelable — call event.preventDefault() to block the update.

PropertyValue
bubblestrue
composedtrue
cancelabletrue
detail.valueProposed new value set (string[])
detail.action"add" or "remove"
detail.itemThe specific value being added/removed (string)

x-multi-combobox-change

Fired after the value has changed.

PropertyValue
bubblestrue
composedtrue
cancelablefalse
detail.valueCurrent value set (string[])

x-multi-combobox-input

Fired on every filter keystroke.

PropertyValue
bubblestrue
composedtrue
cancelablefalse
detail.queryCurrent filter text (string)

x-multi-combobox-toggle

Fired before the panel opens or closes. Cancelable.

PropertyValue
bubblestrue
composedtrue
cancelabletrue
detail.openTarget state (boolean)
detail.source"focus" "pointer" "keyboard" "input" "escape" "outside-click" "focusout" "programmatic"

Slots

SlotContent
default<option value="...">Label</option> elements

CSS custom properties

PropertyDefaultDescription
--x-multi-combobox-bgvar(--x-color-surface)Wrapper background
--x-multi-combobox-fgvar(--x-color-text)Text color
--x-multi-combobox-placeholdervar(--x-color-text-muted)Placeholder color
--x-multi-combobox-border1px solid var(--x-color-border)Default border
--x-multi-combobox-border-focus1px solid var(--x-color-focus-ring)Focus border
--x-multi-combobox-radiusvar(--x-radius-md)Border radius
--x-multi-combobox-min-height2.25remMinimum wrapper height
--x-multi-combobox-font-sizevar(--x-font-size-sm)Font size
--x-multi-combobox-panel-bgvar(--x-color-bg)Panel background
--x-multi-combobox-panel-max-height16remPanel max scroll height
--x-multi-combobox-option-active-bgvar(--x-color-primary)Keyboard-highlighted option
--x-multi-combobox-chip-gap0.25remGap between chips

Chip styling is owned by x-chip. Use --x-chip-* custom properties to theme chips globally.

Shadow parts

PartElementDescription
wrapper<div>Outer container
chip-area<div>Flex container for chips + input
input<input>Filter text field
chevron<span>Dropdown arrow indicator
panel<div>Dropdown listbox
option<div>Individual option in dropdown
empty-msg<div>"No matches" message

Keyboard

KeyBehavior
Arrow DownOpen panel / highlight next option
Arrow UpOpen panel / highlight previous option
EnterAdd highlighted option
EscapeClose panel, clear filter
BackspaceRemove last chip (when input empty)
HomeJump to first option
EndJump to last option

Accessibility

  • Input: role="combobox", aria-expanded, aria-autocomplete="list", aria-controls
  • Panel: role="listbox", aria-multiselectable="true"
  • Options: role="option", aria-disabled when max reached
  • Chip area: role="group", aria-label="Selected values"
  • Active option tracked via aria-activedescendant

Example

<x-multi-combobox placeholder="Pick fruits" max="3">
  <option value="apple">Apple</option>
  <option value="banana">Banana</option>
  <option value="cherry">Cherry</option>
  <option value="date">Date</option>
</x-multi-combobox>
const el = document.querySelector('x-multi-combobox');

// Read selected values
console.log(el.value); // ["apple", "cherry"]

// Set values programmatically
el.value = ["banana", "date"];

// Listen for changes
el.addEventListener('x-multi-combobox-change', e => {
  console.log('Selected:', e.detail.value);
});

Can you improve this documentation?Edit on GitHub

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close