inputshwcz-select

Select

Custom select with a searchable, keyboard-navigable listbox, optional multi-select, insertable options, and remote option insertion.

Attributes

AttributeTypeDefaultDescription
searchablebooleanfalseShows a search field that filters options by text, value, and keywords.
insertablebooleanfalseAllows inserting the current search term as a new option (forces searchable); with send-url the term is sent to the server first.
send-headersstring''JSON object of request headers for the insert request (defaults to Content-Type: application/json).
send-urlstring''Endpoint that receives { term } when inserting; the JSON response must be an option item, otherwise a local option is created from the term.
send-methodstring'POST'HTTP method for the insert request (default POST).
multiplebooleanfalseAllows selecting several options; the value submits as name[].
iconstring''Icon key for the trigger affordance; defaults to the built-in chevrons-up-down icon.
Inherited from InputMixin
AttributeTypeDefaultDescription
disabledbooleanfalseDisables the control so it cannot be interacted with.
formstring''Associates the hidden form input with a form by id, even when the component sits outside that form.
namestring''Field name for the hidden form input; array values submit as name[].
placeholderstring''Placeholder text for the control's empty state.
requiredbooleanfalseMarks the control as required.
valuestring''Initial value of the control, synchronized with the hidden form input.
Inherited from Hwc
AttributeTypeDefaultDescription
i18nstring''Per-instance text overrides as key: text pairs, merged over the global z-i18n script and the built-in defaults.
floatingstring''Floating UI placement options (for example offset and shiftPadding) parsed as key: value pairs.
force-prevent-rerenderbooleanfalseSkips re-rendering after the first render; an existing data-host-inner child is adopted as the rendered DOM.
templatestring''Selector or id of an external element or <template> whose inner content is cloned in place of an inline template[data-fn="template"] child.
Inherited from Base
AttributeTypeDefaultDescription
clsstring''Adds classes to named parts as key: classes pairs; a plain string targets the default part.
stlstring''Adds inline styles to named parts as key: styles pairs; a plain string targets the default part.

Custom Styling (cls / stl)

Default cls target:button · defaultstl target:button

KeyDefault classclsstlDescription
button—yesyesThe combobox trigger button.
button-text—yesyesText span inside the trigger showing the selection.
dividerz-hryesyesDivider between option groups (default z-hr).
dropdownz-select-dropdownyesyesThe floating dropdown panel (default z-select-dropdown).
host-innerz-position-relativeyesyesRendered root wrapper (default z-position-relative).
icon—yesyesTrigger affordance icon slot.
item—yesnoOne option row.
item-activez-activeyesnoClass applied to the focused/selected option (default z-active).
item-check—yesnoSelection check indicator.
item-disabledz-disabledyesnoClass applied to disabled options (default z-disabled).
item-headerz-nav-headeryesyesGroup header row (default z-nav-header).
item-iconz-custom-select-item-iconyesnoOption icon slot (default z-custom-select-item-icon).
item-link—yesnoClickable link/button inside an option row.
item-subtitle—yesnoSecondary option text.
item-textz-custom-select-item-textyesnoOption label text (default z-custom-select-item-text).
item-wrapperz-custom-select-item-wrapperyesnoInner wrapper of an option row (default z-custom-select-item-wrapper).
listz-nav z-dropdown-nav z-overflow-auto z-custom-select-listyesyesThe option listbox (default z-nav z-dropdown-nav z-overflow-auto z-custom-select-list).
searchz-custom-select-searchyesnoSearch field wrapper (default z-custom-select-search).
search-icon—yesnoIcon inside the search field.
search-input—yesnoThe search text input.

CSS Variables

VariableDefaultScopeDescription
--z-custom-select-item-check-margin0.5rem.z-custom-select-item-checkMargin of the selection check.
--z-custom-select-item-icon-margin0.5rem.z-custom-select-item-iconMargin of option icons.
--z-custom-select-list-max-height10rem.z-custom-select-listMaximum height of the scrollable option list.
--z-custom-select-search-icon-margin0.5rem.z-custom-select-searchMargin of the search icon.
--z-custom-select-search-icon-opacity0.5.z-custom-select-searchOpacity of the search icon.
--z-custom-select-search-input-padding0.75rem 0.z-custom-select-searchPadding of the search input.
--z-custom-select-search-padding0 0.75rem.z-custom-select-searchPadding of the search field wrapper.

i18n Keys

KeyDefaultPlaceholdersDescription
button-labelSelect an option—Accessible label of the trigger button. Used in: button, dropdown.
insertInsert—Label of the insert-option action. Used in: item-link.
list-labelOptions—Accessible label of the option listbox. Used in: list.
search-placeholderSearch—Placeholder and accessible label of the search input. Used in: search-input.
selection-count{n} options selectednTrigger text template for multi-select with {n} placeholder.

Icon Keys

KeyIconDescription
checkMarks selected options.
chevrons-up-downDefault trigger affordance. Configured by the icon attribute.
searchSearch field icon.

Events

EventDetailFlagsDescription
z-select:input · from InputMixin{ value: string | string[] }bubblesFires when the selection changes; detail.value carries the new value as a string or string array.
z-select:search · from BaseSelectMixin{ value: string }bubblesFires when the search term changes; detail.value carries the current term.

Data Hooks

AttributeValuesApplies toRoleDescription
data-host-inner · from Hwc—descendantconfigMarks the rendered inner wrapper so force-prevent-rerender can adopt server-rendered DOM without re-rendering.
data-index—descendantmarkerSet by the component on option rows to their global index.
data-key—descendantmarkerSet by the component on option rows to their option key.
data-partdropdowndescendantmarkerMarks the dropdown panel in adopted server-rendered DOM (data-part="dropdown").
data-reactive · from Hwc—descendantconfigOpts the marked child (config script, data source, icons, or template) into live re-parsing when its DOM mutates.

Child Content

script[data-fn="config"][type="application/json"]

JSON configuration script parsed by the base class (i18n, cls, stl, floating).

AttributeRequiredTypeDescription
data-fnyesconfigMarks the script as configuration (value: config).
data-reactivenobooleanRe-parses the configuration when the script mutates.

select[data-fn="data-source"]

Hidden select parsed into grouped option data by the base class.

AttributeRequiredTypeDescription
data-fnyesdata-sourceMarks the select as the data source (value: data-source).
data-reactivenobooleanRe-parses the options when the select mutates.

optgroup · repeatable

Groups options under a label.

AttributeRequiredTypeDescription
labelyesstringGroup header text; also the default group key.
disablednobooleanDisables every option in the group.
data-keynostringOverrides the group key used in the parsed data.
data-keywordsnocomma-separated stringComma-separated keywords stored with the group's data.

option · repeatable

One option entry within the group.

AttributeRequiredTypeDescription
valuenostringValue carried by this option in the parsed data.
disablednobooleanMakes the option non-selectable.
selectednobooleanMarks the option as initially selected.
data-keywordsnocomma-separated stringExtra search terms, comma-separated; searched alongside the label and value.
data-descriptionnostringSecondary text shown under the option label.
data-gidnostringGroup id stored in the option's parsed data.
data-iconnostringIcon key rendered beside the option label, resolved from the icon repository.

option · repeatable

One ungrouped option entry.

AttributeRequiredTypeDescription
valuenostringValue carried by this option in the parsed data.
disablednobooleanMakes the option non-selectable.
selectednobooleanMarks the option as initially selected.
data-keywordsnocomma-separated stringExtra search terms, comma-separated.
data-descriptionnostringSecondary text shown under the option label.
data-gidnostringGroup id stored in the option's parsed data.
data-iconnostringIcon key rendered beside the option label, resolved from the icon repository.

template[data-fn="icons"]

Instance-level icon repository.

AttributeRequiredTypeDescription
data-fnyesiconsMarks the template as an icon source (value: icons).
data-reactivenobooleanRe-parses the icons when the template mutates.

* · repeatable

One icon element.

AttributeRequiredTypeDescription
data-keyyesstringIcon key referenced by $icons.

template[data-fn="template"]

Deferred content template mounted by the base class.

AttributeRequiredTypeDescription
data-fnyestemplateMarks the template for deferred mounting (value: template).
data-reactivenobooleanRe-parses the template when it mutates.

CSS Classes

ClassRoleApplies toDescription
.z-custom-select-item-checkelement.z-custom-selectSelection check indicator.
.z-custom-select-item-iconstate.z-custom-selectOption icon slot.
.z-custom-select-item-textstate.z-custom-selectOption label text.
.z-custom-select-item-wrapperstate.z-custom-selectInner layout of an option row.
.z-custom-select-listelement.z-custom-selectThe scrollable option list.
.z-custom-select-searchstate.z-custom-selectSearch field wrapper at the top of the dropdown.

Keyboard

KeysActionWhen
ArrowDown ArrowUp Home EndMove the focused option; Enter/Space selects it.The dropdown is open.
EscapeCloses the dropdown.—

Accessibility

PartARIADescription
buttonaria-controls="${listboxId}" aria-expanded="${this.$open}" aria-haspopup="listbox" aria-label="${this.getI18nText('button-label', this.defaultI18n)}" role="combobox"Combobox trigger: role="combobox", aria-haspopup="listbox", aria-expanded, aria-controls, labeled by button-label.
button-text—Selection text; no ARIA attributes.
divider—Group divider; no ARIA attributes.
dropdownaria-label="${this.getI18nText('button-label', this.defaultI18n)}" role="dialog"Dropdown panel: role="dialog" labeled by button-label.
host-inner—Root wrapper; no ARIA attributes.
icon—Trigger icon; no ARIA attributes.
itemaria-disabled="${item.disabled ? 'true' : 'false'}" aria-selected="${globalIndex === this.$focused ? 'true' : 'false'}" role="option"Option row: role="option", aria-selected for the focused option, aria-disabled for disabled options.
item-check—Selection check; no ARIA attributes.
item-headerrole="presentation"Group header: role="presentation".
item-icon—Option icon; no ARIA attributes.
item-linkaria-label="${item.text}"Option link labeled by the option text.
item-subtitle—Option subtitle; no ARIA attributes.
item-text—Option label; no ARIA attributes.
item-wrapper—Option row wrapper; no ARIA attributes.
listaria-label="${this.getI18nText('list-label', this.defaultI18n)}" aria-multiselectable="${this.multiple}" role="listbox"Option list: role="listbox" labeled by list-label, aria-multiselectable reflects multiple.
searchrole="search"Search region: role="search".
search-icon—Search icon; no ARIA attributes.
search-inputaria-label="${this.getI18nText('search-placeholder', this.defaultI18n)}" role="searchbox"Search input: role="searchbox" labeled by search-placeholder.
  • Options come from the hidden data-source select (grouped optgroups supported); the trigger is a combobox pointing at the listbox.
  • Search matches option text, value, and data-keywords.