inputshwc
z-selectSelect
Custom select with a searchable, keyboard-navigable listbox, optional multi-select, insertable options, and remote option insertion.
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
searchable | boolean | false | Shows a search field that filters options by text, value, and keywords. |
insertable | boolean | false | Allows inserting the current search term as a new option (forces searchable); with send-url the term is sent to the server first. |
send-headers | string | '' | JSON object of request headers for the insert request (defaults to Content-Type: application/json). |
send-url | string | '' | Endpoint that receives { term } when inserting; the JSON response must be an option item, otherwise a local option is created from the term. |
send-method | string | 'POST' | HTTP method for the insert request (default POST). |
multiple | boolean | false | Allows selecting several options; the value submits as name[]. |
icon | string | '' | Icon key for the trigger affordance; defaults to the built-in chevrons-up-down icon. |
Inherited from InputMixin
| Attribute | Type | Default | Description |
|---|---|---|---|
disabled | boolean | false | Disables the control so it cannot be interacted with. |
form | string | '' | Associates the hidden form input with a form by id, even when the component sits outside that form. |
name | string | '' | Field name for the hidden form input; array values submit as name[]. |
placeholder | string | '' | Placeholder text for the control's empty state. |
required | boolean | false | Marks the control as required. |
value | string | '' | Initial value of the control, synchronized with the hidden form input. |
Inherited from Hwc
| Attribute | Type | Default | Description |
|---|---|---|---|
i18n | string | '' | Per-instance text overrides as key: text pairs, merged over the global z-i18n script and the built-in defaults. |
floating | string | '' | Floating UI placement options (for example offset and shiftPadding) parsed as key: value pairs. |
force-prevent-rerender | boolean | false | Skips re-rendering after the first render; an existing data-host-inner child is adopted as the rendered DOM. |
template | string | '' | 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
| Attribute | Type | Default | Description |
|---|---|---|---|
cls | string | '' | Adds classes to named parts as key: classes pairs; a plain string targets the default part. |
stl | string | '' | 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
| Key | Default class | cls | stl | Description |
|---|---|---|---|---|
button | — | yes | yes | The combobox trigger button. |
button-text | — | yes | yes | Text span inside the trigger showing the selection. |
divider | z-hr | yes | yes | Divider between option groups (default z-hr). |
dropdown | z-select-dropdown | yes | yes | The floating dropdown panel (default z-select-dropdown). |
host-inner | z-position-relative | yes | yes | Rendered root wrapper (default z-position-relative). |
icon | — | yes | yes | Trigger affordance icon slot. |
item | — | yes | no | One option row. |
item-active | z-active | yes | no | Class applied to the focused/selected option (default z-active). |
item-check | — | yes | no | Selection check indicator. |
item-disabled | z-disabled | yes | no | Class applied to disabled options (default z-disabled). |
item-header | z-nav-header | yes | yes | Group header row (default z-nav-header). |
item-icon | z-custom-select-item-icon | yes | no | Option icon slot (default z-custom-select-item-icon). |
item-link | — | yes | no | Clickable link/button inside an option row. |
item-subtitle | — | yes | no | Secondary option text. |
item-text | z-custom-select-item-text | yes | no | Option label text (default z-custom-select-item-text). |
item-wrapper | z-custom-select-item-wrapper | yes | no | Inner wrapper of an option row (default z-custom-select-item-wrapper). |
list | z-nav z-dropdown-nav z-overflow-auto z-custom-select-list | yes | yes | The option listbox (default z-nav z-dropdown-nav z-overflow-auto z-custom-select-list). |
search | z-custom-select-search | yes | no | Search field wrapper (default z-custom-select-search). |
search-icon | — | yes | no | Icon inside the search field. |
search-input | — | yes | no | The search text input. |
CSS Variables
| Variable | Default | Scope | Description |
|---|---|---|---|
--z-custom-select-item-check-margin | 0.5rem | .z-custom-select-item-check | Margin of the selection check. |
--z-custom-select-item-icon-margin | 0.5rem | .z-custom-select-item-icon | Margin of option icons. |
--z-custom-select-list-max-height | 10rem | .z-custom-select-list | Maximum height of the scrollable option list. |
--z-custom-select-search-icon-margin | 0.5rem | .z-custom-select-search | Margin of the search icon. |
--z-custom-select-search-icon-opacity | 0.5 | .z-custom-select-search | Opacity of the search icon. |
--z-custom-select-search-input-padding | 0.75rem 0 | .z-custom-select-search | Padding of the search input. |
--z-custom-select-search-padding | 0 0.75rem | .z-custom-select-search | Padding of the search field wrapper. |
i18n Keys
| Key | Default | Placeholders | Description |
|---|---|---|---|
button-label | Select an option | — | Accessible label of the trigger button. Used in: button, dropdown. |
insert | Insert | — | Label of the insert-option action. Used in: item-link. |
list-label | Options | — | Accessible label of the option listbox. Used in: list. |
search-placeholder | Search | — | Placeholder and accessible label of the search input. Used in: search-input. |
selection-count | {n} options selected | n | Trigger text template for multi-select with {n} placeholder. |
Icon Keys
| Key | Icon | Description |
|---|---|---|
check | Marks selected options. | |
chevrons-up-down | Default trigger affordance. Configured by the icon attribute. | |
search | Search field icon. |
Events
| Event | Detail | Flags | Description |
|---|---|---|---|
z-select:input · from InputMixin | { value: string | string[] } | bubbles | Fires when the selection changes; detail.value carries the new value as a string or string array. |
z-select:search · from BaseSelectMixin | { value: string } | bubbles | Fires when the search term changes; detail.value carries the current term. |
Data Hooks
| Attribute | Values | Applies to | Role | Description |
|---|---|---|---|---|
data-host-inner · from Hwc | — | descendant | config | Marks the rendered inner wrapper so force-prevent-rerender can adopt server-rendered DOM without re-rendering. |
data-index | — | descendant | marker | Set by the component on option rows to their global index. |
data-key | — | descendant | marker | Set by the component on option rows to their option key. |
data-part | dropdown | descendant | marker | Marks the dropdown panel in adopted server-rendered DOM (data-part="dropdown"). |
data-reactive · from Hwc | — | descendant | config | Opts 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).
| Attribute | Required | Type | Description |
|---|---|---|---|
data-fn | yes | config | Marks the script as configuration (value: config). |
data-reactive | no | boolean | Re-parses the configuration when the script mutates. |
select[data-fn="data-source"]
Hidden select parsed into grouped option data by the base class.
| Attribute | Required | Type | Description |
|---|---|---|---|
data-fn | yes | data-source | Marks the select as the data source (value: data-source). |
data-reactive | no | boolean | Re-parses the options when the select mutates. |
optgroup · repeatable
Groups options under a label.
| Attribute | Required | Type | Description |
|---|---|---|---|
label | yes | string | Group header text; also the default group key. |
disabled | no | boolean | Disables every option in the group. |
data-key | no | string | Overrides the group key used in the parsed data. |
data-keywords | no | comma-separated string | Comma-separated keywords stored with the group's data. |
option · repeatable
One option entry within the group.
| Attribute | Required | Type | Description |
|---|---|---|---|
value | no | string | Value carried by this option in the parsed data. |
disabled | no | boolean | Makes the option non-selectable. |
selected | no | boolean | Marks the option as initially selected. |
data-keywords | no | comma-separated string | Extra search terms, comma-separated; searched alongside the label and value. |
data-description | no | string | Secondary text shown under the option label. |
data-gid | no | string | Group id stored in the option's parsed data. |
data-icon | no | string | Icon key rendered beside the option label, resolved from the icon repository. |
option · repeatable
One ungrouped option entry.
| Attribute | Required | Type | Description |
|---|---|---|---|
value | no | string | Value carried by this option in the parsed data. |
disabled | no | boolean | Makes the option non-selectable. |
selected | no | boolean | Marks the option as initially selected. |
data-keywords | no | comma-separated string | Extra search terms, comma-separated. |
data-description | no | string | Secondary text shown under the option label. |
data-gid | no | string | Group id stored in the option's parsed data. |
data-icon | no | string | Icon key rendered beside the option label, resolved from the icon repository. |
template[data-fn="icons"]
Instance-level icon repository.
| Attribute | Required | Type | Description |
|---|---|---|---|
data-fn | yes | icons | Marks the template as an icon source (value: icons). |
data-reactive | no | boolean | Re-parses the icons when the template mutates. |
* · repeatable
One icon element.
| Attribute | Required | Type | Description |
|---|---|---|---|
data-key | yes | string | Icon key referenced by $icons. |
template[data-fn="template"]
Deferred content template mounted by the base class.
| Attribute | Required | Type | Description |
|---|---|---|---|
data-fn | yes | template | Marks the template for deferred mounting (value: template). |
data-reactive | no | boolean | Re-parses the template when it mutates. |
CSS Classes
| Class | Role | Applies to | Description |
|---|---|---|---|
.z-custom-select-item-check | element | .z-custom-select | Selection check indicator. |
.z-custom-select-item-icon | state | .z-custom-select | Option icon slot. |
.z-custom-select-item-text | state | .z-custom-select | Option label text. |
.z-custom-select-item-wrapper | state | .z-custom-select | Inner layout of an option row. |
.z-custom-select-list | element | .z-custom-select | The scrollable option list. |
.z-custom-select-search | state | .z-custom-select | Search field wrapper at the top of the dropdown. |
Keyboard
| Keys | Action | When |
|---|---|---|
| ArrowDown ArrowUp Home End | Move the focused option; Enter/Space selects it. | The dropdown is open. |
| Escape | Closes the dropdown. | — |
Accessibility
| Part | ARIA | Description |
|---|---|---|
button | aria-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. |
dropdown | aria-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. |
item | aria-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-header | role="presentation" | Group header: role="presentation". |
item-icon | — | Option icon; no ARIA attributes. |
item-link | aria-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. |
list | aria-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. |
search | role="search" | Search region: role="search". |
search-icon | — | Search icon; no ARIA attributes. |
search-input | aria-label="${this.getI18nText('search-placeholder', this.defaultI18n)}" role="searchbox" | Search input: role="searchbox" labeled by search-placeholder. |
- Options come from the hidden
data-sourceselect (grouped optgroups supported); the trigger is a combobox pointing at the listbox. - Search matches option text, value, and
data-keywords.