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.

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.

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.

Attributes and Properties

value

DescriptionThe value or array of values of the selected options.
Attributevalue
Typestring | array
Defaultundefined

label

DescriptionText label for the select component.
Attributelabel
Typestring
Defaultundefined

placeholder

DescriptionThe placeholder text displayed in the component when no option is selected.
Attributeplaceholder
Typestring
Defaultundefined

multiple

DescriptionIf set, it allows you to select multiple options at once.
Attributemultiple
Typeboolean
Defaultfalse

disabled

DescriptionIf set, the select component is disabled and cannot be interacted with.
Attributedisabled
Typeboolean
Defaultfalse

clearable

DescriptionIf set, adds a button to clear the selection.
Attributeclearable
Typeboolean
Defaultfalse

maxOptions

DescriptionThe maximum number of options that can be displayed in case of multiple selection.
Attributemax-options
Typenumber
Default1

maxHeight

DescriptionThe maximum height of the drop-down list of options.
Attributemax-height
Typestring
Defaultundefined

find

DescriptionIf set, adds a search box to filter the options.
Attributefind
Typeboolean
Defaultfalse

lazy

DescriptionIf set, the options are only loaded when you click select.
Attributelazy
Typeboolean
Defaultfalse

Option

DescriptionVariant of the appearance of the component. The options are 'default' or 'standard'.
AttributeOption
Typestring
Defaultdefault

trigger

DescriptionThe type of trigger to display the drop-down list. Default 'click'.
Attributetrigger
Typestring
Defaultclick

placement

DescriptionThe location of the drop-down list relative to the select component.
Attributeplacement
Typestring
Defaultbottom-start

Events

NameDescription
wje-select:changeIt is emitted when the selection is changed.

Methods

addOption

DescriptionAdds an option to the select element.
Signature(optionData: any, silent?: boolean, map?: { value: string; text: string; }) => void

addOptions

DescriptionAdds options to the select element.
Signature(optionsData: Array | object, silent?: boolean, map?: { value: string; text: string; }) => void

selectOption

DescriptionSelects the option with the specified value.
Signature(value: string, silent?: boolean) => void

selectOptions

DescriptionSelects one or more options in the select element.
Signature(values: Array|any, silent?: boolean) => void

getSelected

DescriptionReturns the selected options.
Signature() => Array

getAllOptions

DescriptionReturns all options as HTML.
Signature() => NodeList

getSelectedOptions

DescriptionReturns the selected options as HTML.
Signature() => NodeList

CSS Shadow Parts

NameDescription
nativeNative Selector Wrapper.
inputInput field.
clearDelete button.
labelMarking element.
input-wrapperInput field wrapper.
options-wrapperA wrapper of possibilities.
findSearch input field.
popupPopup element.

CSS Custom Properties

NameDescription
--wje-select-border-widthSpecifies the width of the border around the select component. Accepts any valid CSS length unit (e.g. px, rem, em).
--wje-select-border-styleDefines the border style for the select component. It accepts standard CSS border styles such as solid, dashed or dotted.
--wje-select-border-colorSets the border color for the select component. Accepts any valid CSS color value, including variable colors, named colors, and hexadecimal values.
--wje-select-options-border-widthSpecifies the border width for the select drop-down list of options. Accepts any valid CSS length unit.
--wje-select-options-border-styleDefines the border style for the select drop-down list of options. Inherits from a defined CSS variable for consistency.
--wje-select-options-border-colorSets the border color for the drop-down list of select options. Accepts any valid CSS color value.
--wje-select-backgroundSpecifies the background color of the select component. Accepts any valid CSS color value.
--wje-select-line-heightDefines the line height for the text in the select component. Accepts any valid CSS length value, ensuring consistent vertical alignment.
--wje-select-colorSets the text color for the select component. Accepts any valid CSS color value.
--wje-select-border-radiusSpecifies the edge radius for the select component. Specifies corner rounding and accepts any valid CSS length unit or variable.
--wje-select-margin-bottomSets the bottom margin for the select component.

Slots

NameDescription
``The default slot for the selects options.
anchorSlot for anchoring element.
arrowSlot for drop-down list arrow.
startSlot for placing content at the top of the component.
endSlot for placing contents on the end of the component.