Select

Choose from predefined options, search them, or select multiple values.

Live preview
Interact with the component to see results here.
View code
HTML
<sy-select
  placeholder="Choose a team"
  mode="default"
  size="medium"
  maxtagcount="2"
  clearable
  name="team"
  id="sample"
  aria-label="Choose a team"
>
  <sy-option value="1" label="Design"></sy-option>
  <sy-option value="2" label="Development"></sy-option>
  <sy-option value="3" label="Marketing"></sy-option>
</sy-select>

Usage guide

#

Let users choose one or more predefined values. Use sy-option's value and label to distinguish stored values from displayed names.

  1. 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.

  2. 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.

  3. 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.

Feature examples

#

Choose a feature from 30 topics. Explore property settings, method calls, event results, and slot layouts through live examples and code.

Usage examples · Option Overview

Try the selected example. Topics with multiple configurations let you switch between detailed examples.

View code
HTML
Loading the example.

Usage examples · Overview

Try the selected example. Topics with multiple configurations let you switch between detailed examples.

View code
HTML
Loading the example.

Property · Clearable

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Default Value

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Disabled

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Empty

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Error

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Loading

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Max Tag Count

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Mode

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · No Native Validity

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Placeholder

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Readonly

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Required

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Selected Options

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Size

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Methods · CheckValidity

Use the example's buttons to call methods and inspect their results.

View code
HTML
Loading the example.

Methods · ClearValue

Use the example's buttons to call methods and inspect their results.

View code
HTML
Loading the example.

Methods · Hide

Use the example's buttons to call methods and inspect their results.

View code
HTML
Loading the example.

Methods · ReportValidity

Use the example's buttons to call methods and inspect their results.

View code
HTML
Loading the example.

Methods · SetCustomError

Use the example's buttons to call methods and inspect their results.

View code
HTML
Loading the example.

Methods · SetValue

Use the example's buttons to call methods and inspect their results.

View code
HTML
Loading the example.

Events · Blured

Interact with the component to see event names and payloads in the live preview below.

View code
HTML
Loading the example.

Events · Cleared

Interact with the component to see event names and payloads in the live preview below.

View code
HTML
Loading the example.

Events · Focused

Interact with the component to see event names and payloads in the live preview below.

View code
HTML
Loading the example.

Events · InputChanged

Interact with the component to see event names and payloads in the live preview below.

View code
HTML
Loading the example.

Events · Opened

Interact with the component to see event names and payloads in the live preview below.

View code
HTML
Loading the example.

Events · Removed

Interact with the component to see event names and payloads in the live preview below.

View code
HTML
Loading the example.

Events · Selected

Interact with the component to see event names and payloads in the live preview below.

View code
HTML
Loading the example.

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 / PropertyTypeDefaultDescription
booleanfalseShow a button to clear the current value.
booleanfalseBlock user interaction and keyboard focus.
booleanfalseDisplay the current value while preventing edits.
booleanfalseShow an empty-list state.
booleanfalseShow an error state.
booleanfalseHide the item from view.
booleanfalseIndicate that processing is in progress.
number0Number 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.
booleanfalseFail form validation when no value is provided.
string''Field name used in FormData.
booleanfalseUse the app's error UI instead of the browser's built-in error display. checkValidity still performs validation.
booleanfalseUsed 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

EventDetailDescription
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

MethodReturnsDescription
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

SlotDescription
Component body or child items.
Validation error message.

<sy-option>

Properties

Attribute / PropertyTypeDefaultDescription
booleanfalseBlock user interaction and keyboard focus.
string''Label describing the item.
booleanfalseDisplay the current value while preventing edits.
string''Current value or item identifier.
booleanfalseTooltip behavior for values or helper text.
booleanfalseIndicate whether the option is selected.
booleanfalseHide the item from view.
booleanfalseShow an empty-list state.
booleanfalseIndicate that processing is in progress.
booleanfalseIndicate whether the option was added through tag input.
booleanfalseIndicate whether the option is active during keyboard navigation.

Events

EventDetailDescription
CustomEvent<{ value: string; label: string }>Emitted when keyboard navigation changes the active item.

Slots

SlotDescription
Component body or child items.