shadow
The Select element extends the capabilities of the standard HTML select element to provide an enhanced user experience.
It supports both single and multiple option selection using the multiple attribute.
It offers advanced features such as clearable content with the clearable attribute, searching through options with find, and lazy loading to optimize performance with the lazy attribute.
When multiple options are selected, the selected items are displayed as chips with a configurable maximum number of items displayed.
The component also supports dynamic loading of options from external sources via the Options element.
By default, the selection allows the user to select only one option. Including the Icon element will also display the selected icon next to the option.
Adding the multiple attribute allows the user to select multiple options.
Adding the clearable attribute allows the user to remove all selected options by clicking on the icon.
Adding the disabled attribute prevents the user from interacting with Select.
Using the Options component, a dynamically generated list of options is also supported, which is asynchronously retrieved from the specified URL.
When no options are returned, or when search produces no match, the dropdown shows an empty state message.
This message is resolved from the wj.select.empty localization key. To change it in the library, update the matching language file in packages/translations, for example packages/translations/sk-sk.js or packages/translations/en-gb.js. The active translation is selected from lang on the component or one of its ancestors.
export const enGb = {
'wj.select.empty': 'No data',
};
Adding the standard attribute will display the Select in the style of a standard HTML Select.
Adding the lazy attribute will load options only when needed. This can be useful for large amounts of options or when loading from external sources.
Adding the find attribute displays an input field that allows the user to search for options in the list. The user can enter text and the list is automatically filtered according to the text entered.
By combining the lazy and find attributes, options are only loaded when the user starts typing in the input field. This can be useful for large amounts of options or when loading from external sources.
Use wje-select when users need to enter values, choose options, or trigger form-related actions.
Do not use it as a decorative element without interaction. Prefer presentational components in that case.
Always provide a label (label/aria-label), keep keyboard support, and surface clear validation feedback.
- Keep validation rules and error behavior consistent across the entire form.
- Show loading or disabled states during async operations.
- Split complex forms into smaller sections with immediate feedback.
| Description | Controls whether the select dropdown is currently open. |
| Attribute | active |
| Type | boolean |
| Default | - |
| Description | Getter for the customErrorDisplay attribute. |
| Attribute | custom-error-display |
| Type | boolean |
| Default | false |
| Description | Sets or removes the disabled state for the associated elements. |
| Attribute | disabled |
| Type | boolean |
| Default | false |
| Description | Sets the lazy attribute on the element. If the provided value is truthy, the lazy attribute is added. If the value is falsy, the lazy attribute is removed. |
| Attribute | lazy |
| Type | boolean |
| Default | false |
| Description | Sets the maximum height value for the element. If a value is provided, it sets the 'max-height' attribute on the element. If no value is provided, it removes the 'max-height' attribute from the element. |
| Attribute | max-height |
| Type | string|null |
| Default | auto |
| Description | Sets the maximum number of options allowed. |
| Attribute | max-options |
| Type | number | object |
| Default | 1 |
| Description | Sets or removes the 'no-size' attribute on an element. |
| Attribute | no-size |
| Type | boolean |
| Default | false |
| Description | Gets the value of the offset attribute of the current element. If the offset attribute is not present, returns a default value of '0'. |
| Attribute | offset |
| Type | string |
| Default | 5 |
| Description | Checks if the 'readonly' attribute is present on the element. |
| Attribute | readonly |
| Type | boolean |
| Default | false |
| Description | Sets the trigger value. |
| Attribute | trigger |
| Type | string |
| Default | click |
| Description | Sets the value for the form field. Converts the input value into a FormData object if it is not already an array, splitting by spaces if necessary, and sets the internal form value as well as the selected values. |
| Attribute | value |
| Type | string|Array |
| Default | - |
| Name | Description |
|---|
wje-popup:content-ready | Emitted when the wje-popup:content-ready event is dispatched. |
wje-select:change | Emitted when the component value changes. |
| Description | Returns all the options as HTML. |
| Signature | () => NodeList |
| Description | Adds a new option to the component. |
| Signature | (optionData: object, silent?: boolean, map?: object) => void |
| Description | Adds one or more options to a collection. If the input is an array, it adds each option within the array. Otherwise, it adds a single option. |
| Signature | (optionsData: Array | object, silent?: boolean, map?: object) => void |
| Description | Selects an option from the available options within the component. |
| Signature | (value: string, silent?: boolean) => void |
| Description | Selects multiple options based on the provided values. If a single value is provided, it selects that option. If an array of values is provided, it iterates through the array and selects each option. |
| Signature | (values: any|any[], silent?: boolean) => void |
| Description | Clears all selected options and resets selections. The method ensures that all options are deselected, updates the internal state, validates the selections, propagates the validation status, and indicates invalid state if necessary. |
| Signature | () => void |
No CSS shadow parts available for this component.
No CSS custom properties available for this component.
No slots available for this component.