Select
Choose from predefined options, search them, or select multiple values.
Usage guide
#Let users choose one or more predefined values. Use sy-option's value and label to distinguish stored values from displayed names.
Write the error message in the error slot.
Inside the component, add <span slot="error">Error message</span>. You can include links and other guidance as well as text. For inputs supporting noNativeValidity, enable it to show this guidance instead of a browser popup. Switch always displays errors below the component.
Report business rule failures with setCustomError().
For example, if the server rejects a duplicate value, update the error slot and call setCustomError(). This method does not take a message argument. A custom error also blocks form submission.
Clear the error after resolving it and check whether submission is allowed.
Use clearCustomError() to clear a business rule error. Required-field and format validation remain active. await checkValidity() returns true or false; reportValidity() validates and displays errors. Read valid named values through FormData on submission.
Default selection
Use for one choice from a short list. Set the initial selection with defaultValue.
Search and select
mode="searchable" suits large lists that users narrow by name.
Multiple selection
Use mode="multiple" to select several candidates and maxTagCount to control visible tags.
Accept new values too
Use mode="tag" when users need to add values outside the list.
Examples
#Feature examples
#Choose a feature from 30 topics. Explore property settings, method calls, event results, and slot layouts through live examples and code.
No matching features.
API reference
#Hover over a name or focus it with the keyboard to see the code. On touch screens, tap the name.
<sy-select>
Properties
| Attribute / Property | Type | Default | Description |
|---|---|---|---|
boolean | false | Show a button to clear the current value. | |
boolean | false | Block user interaction and keyboard focus. | |
boolean | false | Display the current value while preventing edits. | |
boolean | false | Show an empty-list state. | |
boolean | false | Show an error state. | |
boolean | false | Hide the item from view. | |
boolean | false | Indicate that processing is in progress. | |
number | 0 | Number of selected tags shown at once. Set to 0 to show all. | |
string | '' | Initially selected value. | |
string | '' | Placeholder shown when the value is empty. | |
'small' | 'medium' | 'large' | 'medium' | Component size. | |
'default' | 'searchable' | 'multiple' | 'tag' | 'default' | Standard, searchable, multiple-selection, or tag-input mode. | |
boolean | false | Fail form validation when no value is provided. | |
string | '' | Field name used in FormData. | |
boolean | false | Use the app's error UI instead of the browser's built-in error display. checkValidity still performs validation. | |
boolean | false | Used internally with Tree Select. Keep the default for a regular Select. | |
{ value: string; label?: string }[] | [] | Array of selected option objects. Pass objects and arrays as JavaScript properties. |
Events
| Event | Detail | Description |
|---|---|---|
CustomEvent<void> | Emitted when the list opens. | |
CustomEvent<any> | Emitted when a selected item is removed. | |
CustomEvent<any> | Emitted when the user selects an item. | |
CustomEvent<void> | Emitted when focus is received. | |
CustomEvent<void> | Emitted when focus is lost. | |
CustomEvent<string> | Emitted when the search input changes. | |
CustomEvent<void> | Emitted when all selections are cleared. |
Methods
| Method | Returns | Description |
|---|---|---|
Promise<void> | Select options matching the specified value string or array. An empty array clears the selection. | |
Promise<void> | Clear only the search input, keeping the selected options. | |
Promise<void> | Close the open options list. | |
Promise<void> | Set a custom error state. | |
Promise<void> | Clear the custom error state. | |
Promise<string> | Return the current validation state. | |
Promise<boolean> | Return true if the current constraints are satisfied, otherwise false. | |
Promise<boolean> | Validate the current value and display errors to the user. |
Slots
| Slot | Description |
|---|---|
| Component body or child items. | |
| Validation error message. |
<sy-option>
Properties
| Attribute / Property | Type | Default | Description |
|---|---|---|---|
boolean | false | Block user interaction and keyboard focus. | |
string | '' | Label describing the item. | |
boolean | false | Display the current value while preventing edits. | |
string | '' | Current value or item identifier. | |
boolean | false | Tooltip behavior for values or helper text. | |
boolean | false | Indicate whether the option is selected. | |
boolean | false | Hide the item from view. | |
boolean | false | Show an empty-list state. | |
boolean | false | Indicate that processing is in progress. | |
boolean | false | Indicate whether the option was added through tag input. | |
boolean | false | Indicate whether the option is active during keyboard navigation. |
Events
| Event | Detail | Description |
|---|---|---|
CustomEvent<{ value: string; label: string }> | Emitted when keyboard navigation changes the active item. |
Slots
| Slot | Description |
|---|---|
| Component body or child items. |