Select
Usage
Select lets users pick one or more values from a list of predefined options instead of entering free-form text. Use it when the list may be longer than a simple inline choice group would comfortably show, or when searching, custom option labels, or multi selection would improve the picking experience.
import { MtSelect } from "@shopware-ag/meteor-component-library";
Examples
Multiple selection
Enable enableMultiSelection so users can choose several values at once.
API reference
Props
| Prop | Type | Default |
|---|---|---|
options *An array of objects with the labelProperty and valueProperty. | unknown[] | |
errorAn error in your business logic related to this field.
For example: {"code": 500, "detail": "Error while saving"} | Record<string, any> | null |
labelThe label for the select field itself. | string | "" |
is-inheritance-fieldDetermines if the field is inheritable. | boolean | false |
is-inheritedToggles the inheritance visualization. | boolean | false |
disabledDisables or enables the select field. | boolean | false |
placeholderThe placeholder for the select field. | string | "" |
model-valueDependent on multiSelection, either a single value or an array of values. | string | number | boolean | object | unknown[] | null | null |
smallRender the select field in small without a search input | boolean | false |
disable-inheritance-toggleDetermines the active state of the inheritance toggle. | boolean | false |
is-loadingToggles the loading state of the select field. | boolean | false |
label-propertyThe object key of the label property. Can be a single string or an array of strings.
If an array is provided, the first property that has a non-empty value will be used. | string | string[] | "label" |
value-propertyThe object key to use for the value. | string | "value" |
always-show-placeholderDetermines if the placeholder should be shown even when there are no selections. | boolean | true |
enable-multi-selectionToggles if either one or more items can be selected. | boolean | false |
value-limitThe number of items that are expanded by default. | number | 5 |
hide-clearable-buttonToggles a button to clear all selections. | boolean | false |
highlight-search-termDetermines to highlight the searched term or not. | boolean | true |
search-functionUsed to implement a custom search function.
Parameters passed: { options, labelProperty, valueProperty, searchTerm } | Function | ({ options, labelProperty, searchTerm, }: {
options: any;
labelProperty: string | string[];
searchTerm: string;
}) => {
return options.filter((option: any) => {
// If labelProperty is an array, check each property
if (Array.isArray(labelProperty)) {
for (const property of labelProperty) {
const label = getPropertyValue(option, property);
if (label &&
typeof label === "string" &&
label.toLowerCase().includes(searchTerm.toLowerCase())) {
return true;
}
}
return false;
}
// Original behavior for string labelProperty
const label = getPropertyValue(option, labelProperty);
if (!label) {
return false;
}
return label.toLowerCase().includes(searchTerm.toLowerCase());
});
} |
on-update:model-value | ((...args: any[]) => any) | undefined | |
on-change | ((...args: any[]) => any) | undefined | |
on-inheritance-remove | ((...args: any[]) => any) | undefined | |
on-inheritance-restore | ((...args: any[]) => any) | undefined | |
on-item-add | ((...args: any[]) => any) | undefined | |
on-item-remove | ((...args: any[]) => any) | undefined | |
on-display-values-expand | ((...args: any[]) => any) | undefined | |
on-paginate | ((...args: any[]) => any) | undefined | |
on-search-term-change | ((...args: any[]) => any) | undefined |
Exposed
| Name | Type |
|---|---|
t | ComposerTranslation<{ en: { messageNoResults: string; }; de: { messageNoResults: string; }; }, "en" | "de", RemoveIndexSignature<{ [x: string]: LocaleMessageValue<VueMessageType>; }>, never, "messageNoResults", "messageNoResults"> |
getKey | any |
searchTerm | string |
limit | number |
searchResults | never[] |
isSearchResultsLoading | boolean |
visibleValues | any[] |
totalValuesCount | number |
invisibleValueCount | number |
currentValue | string | number | boolean | object | unknown[] | null |
visibleResults | any[] |
componentClasses | Record<string, boolean> |
Best practices
Do
- Use a clear field label so users understand what they are choosing.
- Keep option labels concise and easy to scan.
- Use
enableMultiSelectiononly when selecting multiple values is a real user need. - Set
labelPropertyandvaluePropertyexplicitly when your option shape differs from the defaults. - Add hint or help text when the selection rules need extra explanation.
Don't
- Do not use Select when users should enter arbitrary text instead of choosing from known values.
- Do not use a long select list when a smaller visible choice group would be easier to compare directly.
- Do not rely on placeholder text as the only instruction for the field.
- Do not mix unclear or duplicated option labels, especially in searchable lists.
- Do not enable multi selection when the form should store exactly one value.
Behavior
- Select supports both single and multiple selection.
modelValuecan be a single value, an option object, or an array depending on the selection mode andvalueProperty. - The component searches within the provided options by default and supports a custom
searchFunctionwhen filtering needs to follow business-specific rules. labelPropertycan be a string or an array of property paths. When an array is used, the first non-empty value is used as the visible label.- Shared field features such as
hint,error, prefix and suffix content, and inheritance handling work the same way as in other form fields. smallrenders a compact variant without the inline search input, which is better suited to tighter layouts.- Use
selectionLabelPropertyto customize how selected items are rendered in the closed field. - Use the
result-itemslot orresultLabelPropertywhen result rows need richer formatting than a plain text label. - Use the
before-item-listandafter-item-listslots for supporting content around the result list, such as guidance or actions.
Accessibility
- Provide a clear field label or other nearby visible context so users understand what the selection controls.
- Keep option labels distinct so users can tell similar choices apart while searching or navigating with the keyboard.
- Use help text when multiple selection, custom option rendering, or inherited values might otherwise be unclear.
Related components
- Radio Group: when a small set of options should stay visible so users can compare them directly.
- Checkbox: when users are toggling independent options on and off rather than choosing from a shared option set.