Component Combobox
A combobox is a hybrid form element that combines a searchable input field with a select dropdown menu. Users can type a value and/or choose from a list of predefined options.
Example
Props
Attr | Type | Default | Docs |
---|---|---|---|
badge-dismissible | boolean | true | This property will show/hide the close |
data | string | This property is used as the API layer to populate the combobox popover items. The data structure should be a stringified array of objects. Each object should have keys for | |
error | string | null | This property can be used to set an error. If a non-empty string is given, it will be used as the error message. |
format-checked | string | 'checked' | This property can be used to map your data structure to the |
format-disabled | string | 'disabled' | This property can be used to map your data structure to the |
format-label | string | 'label' | This property can be used to map your data structure to the |
format-name | string | 'name' | This property can be used to map your data structure to the |
format-value | string | 'value' | This property can be used to map your data structure to the |
help | string | '' | This property can be used to set help text. |
hide-label | boolean | false | This property will visually hide the label. A label is still required for screenreader support. |
input-id | string | generateId('som-combobox-') | This property can be used to specifically set an ID to the combobox field. If an ID is not provided, it will be dynamically generated. |
is-clearable | boolean | true | This property will show/hide the |
label | string | '' | This property can be used to set a label. |
no-results-message | string | 'No results found' | This property sets the message that will display if no results are found. Defaults to "No results found". |
placeholder | string | '' | This property can be used to set a placeholder text. |
required | boolean | false | This boolean can be used to set the combobox as required. |
required-ind | "none" | "optional" | "required" | This property is used to override the required indicator. By default, forms elements will show an | |
search-field | string | This property is used to set the key to search against. Default behavior will search against | |
type | "checkbox" | "radio" | 'checkbox' |
Methods
Name | Returns | Docs |
---|---|---|
addItem |
| This method will add a specific item to the selected list of items when passing the label value as a string. |
clearSelectedItems |
| This method will clear all selected items and close the popover if open. |
closePopover |
| This method will close the list of results. |
deleteItem |
| This method will delete a specific item from the selected list of items when passing the label value as a string. |
openPopover |
| This method will open the list of results. |
Events
Event | Detail | Docs |
---|---|---|
comboboxClosed | any | This event is triggered after combobox is closed. |
comboboxInput | any | This event is emitted when a keyboard input occurs. |
comboboxOpened | any | This event is triggered after combobox is opened. |
itemAdded | any | This event is emitted when an item is added. |
itemRemoved | any | This event is emitted when an item is removed. |
itemsRemoved | any | This event is emitted when all items are removed. |
Do you have an idea, or want to help us improve this page? Reach out to us via email.
DTMB-DG-Support@michigan.govNeed help? Visit our Support page to learn how to get assistance, troubleshoot issues, and connect with the team.