Skip to main content

Select

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. If the select is placed in a container with overflow: hidden, in a dialog, or in another overlay, use the portaled attribute.

Basic usage

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.

Selecting multiple items

Adding the multiple attribute allows the user to select multiple options.

Clearable

Adding the clearable attribute allows the user to remove all selected options by clicking on the icon.

Disabled

Adding the disabled attribute prevents the user from interacting with Select.

Dynamic list of options

Using the Options component, a dynamically generated list of options is also supported, which is asynchronously retrieved from the specified URL. If no options are returned, or the search does not return a match, the dropdown displays an empty status with the message No data. The text of this message is taken from the localization key wj.select.empty. To change it in the library, edit the appropriate language file in packages/translations, for example packages/translations/en-sk.js or packages/translations/en-gb.js. The translation used is selected by the lang value on the component or parent element.

export const skSk = {
// ...
'wj.select.empty': 'No data',
};

Portaled

Adding the portaled attribute will move the dropdown with the list of options to the portal, similar to wje-dropdown. This avoids list clipping in parents with overflow: hidden or in more complex overlay scenarios. Select still works with the original wje-option elements and also supports dynamic options from wje-options.

Standard

Adding the standard attribute will display the Select in the style of a standard HTML Select.

Lazy loading

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.

Find

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.

When to use

Use wje-select when the user enters a value, selects options, or performs an action on a form.

When not to use

Don't just use it as a visual decorative element without interaction. In this case, give priority to the presentation components.

Accessibility

Always link the component to the description (label/aria-label), keep keyboard control, and display a clear message on validation errors.

  • Keep validation rules and error states consistent across the entire form.
  • For asynchronous operations, display the load status or disabled status.
  • For complex forms, prefer smaller sections and immediate feedback.

Attributes and properties

active

PopisUrčuje, či je výberové menu otvorené.
Atribútactive
Typboolean
Predvolené-

customErrorDisplay

PopisRiadi validáciu alebo stavové hlášky pre voľbu custom-error-display.
Atribútcustom-error-display
Typboolean
Predvolenéfalse

disabled

PopisVypína používateľskú interakciu s komponentom.
Atribútdisabled
Typboolean
Predvolenéfalse

lazy

PopisUrčuje, či je voľba lazy zapnutá a ovplyvňuje správanie komponentu.
Atribútlazy
Typboolean
Predvolenéfalse

maxHeight

PopisNastavuje rozmery alebo veľkosť pre voľbu max-height.
Atribútmax-height
Typstring|null
Predvolenéauto

maxOptions

PopisNastavuje číselnú hodnotu používanú vo voľbe max-options.
Atribútmax-options
Typnumber | object
Predvolené1

noSize

PopisNastavuje rozmery alebo veľkosť pre voľbu no-size.
Atribútno-size
Typboolean
Predvolenéfalse

offset

PopisNastavuje textovú hodnotu uloženú vo voľbe offset.
Atribútoffset
Typstring
Predvolené5

portaled

PopisUrčuje, či je voľba portaled zapnutá a ovplyvňuje správanie komponentu.
Atribútportaled
Typboolean|string
Predvolené-

readonly

PopisZabráni používateľovi upravovať hodnotu.
Atribútreadonly
Typboolean
Predvolenéfalse

trigger

PopisNastavuje textovú hodnotu uloženú vo voľbe trigger.
Atribúttrigger
Typstring
Predvolenéclick

value

PopisNastavuje aktuálnu hodnotu komponentu.
Atribútvalue
Typstring|Array
Predvolené-

Events

NázovPopis
wje-select:changeVyvolá sa pri zmene hodnoty komponentu.
wje-popup:content-readyVyvolá sa pri odoslaní udalosti wje-popup:content-ready.

Methods

getAllOptions

PopisVráti všetky položky z aktuálneho stavu komponentu.
Signatúra() => NodeList

addOption

PopisPridá položku do spravovanej kolekcie komponentu.
Signatúra(optionData: object, silent?: boolean, map?: object) => void

addOptions

PopisPridá položky do spravovanej kolekcie komponentu.
Signatúra(optionsData: Array | object, silent?: boolean, map?: object) => void

selectOption

PopisVyberie položku a aktualizuje aktívny stav.
Signatúra(value: string, silent?: boolean) => void

selectOptions

PopisVyberie položky a aktualizuje aktívny stav.
Signatúra(values: any|any[], silent?: boolean) => void

clearSelections

PopisVyčistí výbery a obnoví súvisiace hodnoty.
Signatúra() => void

CSS shadow parts

Pre tento komponent nie sú dostupné žiadne CSS časti tieňa.

CSS custom variables

Pre tento komponent nie sú dostupné žiadne vlastné CSS vlastnosti.

Slots

Pre tento komponent nie sú dostupné žiadne sloty.