Skip to main content

SelectInputMulti

Allows users to select multiple values from a provided list of options.

github
View source code
Deprecation notice

SelectInputMulti is deprecated. Use SelectInput with the asMulti prop instead.

// Before
<SelectInputMulti options={options} value={value} onChange={onChange} />
// After
<SelectInput asMulti options={options} value={value} onChange={onChange} />

Note that modalHeading has been renamed to menuHeading on SelectInput.

import { SelectInputMulti } from '@uhg-abyss/mobile';
() => {
const form = useForm();
return (
<FormProvider state={form}>
<SelectInputMulti
model="select-input-multi-sandbox"
label="Your favorite framework/library"
isSearchable
options={[
{ value: 'react', label: 'React' },
{ value: 'ng', label: 'Angular' },
{ value: 'svelte', label: 'Svelte' },
{ value: 'vue', label: 'Vue' },
{ value: 'alpine', label: 'Alpine' },
{ value: 'ember', label: 'Ember' },
{ value: 'stimulus', label: 'Stimulus' },
{ value: 'preact', label: 'Preact' },
]}
/>
</FormProvider>
);
};

Usage

Use the options prop to supply the options that can be selected. options is an array of objects, where each object should have two properties:

  • label, a string which is how the option will be displayed in the list
  • value, a string which is the unique identifier for the option

Sections can also be specified, in which case the section object should have title, value, and items properties instead of label and value (See Titles for more details).

options = {
[
{ label: 'Item 1', value: 'item1' },
{ label: 'Item 2', value: 'item2', isDisabled: true },
{ label: 'Item 3', value: 'item3' },
{ label: 'Item 4', value: 'item4' },
{ label: 'Item 5', value: 'item5' },
]
}

Using the useForm hook with FormProvider sets state for the component.

useState

Using the useState hook gets values from the component state.

Titles

To create sections in the list, pass objects into the options array that have the title, value, and items properties. title specifies the name of the title, which will be bolded and not selectable, value is the unique identifier for the title, while items should contain the options within that section (with the same label/value format as normal).

options = {
[
{
title: 'Title 1',
value: 'Title1',
items: [
{ label: 'item 1', value: 'item11' },
{ label: 'item 2', value: 'item12', isDisabled: true },
{ label: 'item 3', value: 'item13' },
],
},
]
}

Label

Use the label prop to display a label above the input menu.

Required

Form Compatibility
useState
useForm

Use the isRequired prop to display an asterisk next to the label when using useState.

Hint Text

Use the hintText prop to display text below the label.

Help Content

Use the helpContent prop to display a help icon in the top right of the container, which will display the provided content in a modal screen when pressed.

Error Message (useState)

Form Compatibility
useState
useForm

Use the errorMessage prop to display a custom error message below the menu when using useState.

Success Message

Form Compatibility
useState
useForm

Use the successMessage prop to display a custom success message below the menu.

Disabled

Set the isDisabled prop to true to disable the select list input field so users cannot select a value.

Disable Option Items

Disable an individual option item by setting the isDisabled key to true within the object.

Select All

By setting the selectAll property to true you can make a "Select All" option visible at the top of the dropdown. When selected, all options will be selected. When deselected, all options will be deselected.

Searchable

Use the isSearchable prop to display an input field for the user to search/filter the list of options that is located inside the dropdown.

Fuse.js

Search Bar filtering uses the Fuse.js library to fuzzy filter results. What is fuzzy searching? Generally speaking, fuzzy searching (more formally known as approximate string matching) is the technique of finding strings that are approximately equal to a given pattern (rather than exactly).

Fuse Data

The options prop is the information that fuse will filter on and display in the search dropdown.

Fuse Configurations

The fuse search options are set by default as follows. The keys are set to label and cannot be changed.

{
keys: ['label', 'items.label'],
includeMatches: true,
findAllMatches: true,
threshold: 0,
ignoreLocation: true,
minMatchCharLength: searchText.length,
}

Custom Fuse Configurations

You can customize the fuse filter by following the documentation on Fuse and passing your configurations into the fuseConfigs prop. To get the filtered list back, be sure includeMatches is always set to true.

Custom Filtering

Use the customFilter prop to override the fuse.js filtering. The results returned from your customFilter function should be passed into the options prop. In the example function below, the filter is checking the first letter typed in the search bar against the first letter of each item in the list. If the letter is a match the item is included in the filtered list. Any 'type-ahead' styles will not be applied when a custom filtering function is being used.

Notes

In order for a user to select an item from the menu while the softkeyboard is up, the prop keyboardShouldPersistTaps is set to 'always'. If the menu is contained in a ScrollView, keyboardShouldPersistTaps={'always'} should be set with in that view. This allows for the keyboard to remain open and an item to be selected on initial tap.

SelectInputMulti Props

NameTypeDefaultRequiredDescription
customFilter
( searchText: string, list: SelectInputMultiOptionType[] ) => any[] | undefined
--
Custom function used for search
errorMessage
string | undefined
--
Error message to be displayed below the select input field
fuseConfigs
Fuse.IFuseOptions<any> | undefined
--
Configs for Fuse
hasTitleSeparator
boolean | undefined
false
-
When true, places a top border along each title in the options list. This will not display without titles being specified
helpButtonAccessibilityLabel
string | undefined
--
Set the accessibility label for the help button
helpContent
React.ReactNode | undefined
--
When defined, displays a help icon that can be tapped to view the provided content in a modal screen
hintText
string | undefined
--
Text displayed below the select input field
isDisabled
boolean | undefined
false
-
Flag to enable/disable the select list. If true, the select list will be disabled
isRequired
boolean | undefined
false
-
Flag to add an asterisk next to the label, indicating that the field is required. This is independent of form validation and is only for visual purposes.
isSearchable
boolean | undefined
false
-
Flag to enable/disable the select list search/filter feature
label
string | undefined
--
Select list label
modalHeading
string | undefined
--
Heading of the input modal
model
never | string | undefined
--
model is only used when the input is bound to a form via useForm. Model name used to bind the input to the form state. Only used inside a
FormProvider.
onChange
(value: string[]) => void | undefined
--
Callback fired every time the value changes
options
SelectInputMultiOptionType[] | undefined
'[]'
-
List of options selectable in the select list input. { label: string, value: string }
placeholder
string | undefined
--
The rendered string when no option is selected
selectAll
boolean | undefined
false
-
Toggles the Select All option
showHint
boolean | undefined
--
Shows the hint text
successMessage
string | undefined
--
Success message to be displayed below the select input field
validations
Validations | undefined
--
Set rules for the input to be valid. Valid in both useState and
useForm modes. Set rules for the input to be valid.
value
string[] | undefined
'[]'
-
Option value or list of option values selected in the select list input

SelectInputMulti Classes

Class NameDescription
abyss-select-input-multi-rootRoot element
abyss-select-input-multi-headerHeader element
abyss-select-input-multi-labelLabel element
abyss-select-input-multi-hint-textInput hint text
abyss-select-input-multi-help-buttonHelp button
abyss-select-input-multi-help-modalHelp modal
abyss-select-input-multi-open-iconMenu open icon
abyss-select-input-multi-modalDeprecated. Styled via BottomSheet. Will be removed in V3.
abyss-select-input-multi-menu-listMenu list
abyss-select-input-multi-messageMessage element
abyss-select-input-search-barMenu search bar
abyss-select-input-footerDeprecated. Styled via BottomSheet footer container. Will be removed in V3.
abyss-select-input-footer-buttonMenu footer submit button
abyss-input-help-iconHelp icon element
abyss-input-help-modal-footerHelp modal footer
abyss-input-help-modal-close-buttonHelp modal close button
abyss-select-input-text-containerText container
abyss-select-input-textSelect input text
abyss-select-input-placeholderPlaceholder text
abyss-select-input-multi-containerInteractive input container
abyss-select-input-menu-containerMenu container
abyss-select-input-menu-list-titleMenu list section title
abyss-select-input-close-iconDeprecated. Styled via BottomSheet close icon. Will be removed in V3.
abyss-select-input-menu-item-containerMenu item container
abyss-select-input-menu-itemMenu item
abyss-select-input-menu-item-textMenu item text
abyss-select-input-menu-item-checkboxMenu item checkbox
abyss-select-input-menu-item-select-all-checkboxSelect all checkbox
abyss-input-message-iconMessage icon
abyss-input-message-textMessage text

SelectInputMulti Translations

Translation KeyValue
helpHelp
closeClose
errorError
successSuccess
checkedChecked
notCheckedNot Checked
mixedMixed
SelectInput.placeholderSelect an Option

SelectInputMulti Tokens

Token NameValue
input-header.color.text.label
#4B4D4F
input-header.color.text.hint
#4B4D4F
input-header.color.icon.help.rest
#196ECF
input-header.color.icon.help.active
#004BA0
input-message.color.text.error
#990000
input-message.color.text.success
#007000
input-message.color.icon.error
#990000
input-message.color.icon.success
#007000
input-field.color.surface.default
#FFFFFF
input-field.color.surface.disabled
#F3F3F3
input-field.color.text.input
#4B4D4F
input-field.color.border.rest.default
#4B4D4F
input-field.color.border.rest.error
#990000
input-field.color.border.rest.success
#007000
input-field.color.border.active.default
#196ECF
input-field.color.border.active.error
#990000
input-field.color.border.active.success
#007000
input-field.color.icon.utility.rest
#4B4D4F
input-field.color.icon.utility.disabled
#929496
input-field.color.icon.utility.active
#323334
input-field.border-radius.all.container
4
input-field.border-width.all.container.rest
1
input-field.border-width.all.container.active
3
input-header.sizing.all.icon.help
24
input-message.sizing.all.icon.leading
20
input-field.sizing.icon.all.utility
20
input-field.sizing.icon.all.picker
20
input-container.spacing.gap.vertical.container
8
input-header.spacing.gap.horizontal.container
12
input-header.spacing.gap.horizontal.label
4
input-header.spacing.gap.vertical.content
4
input-message.spacing.gap.horizontal.container
4
input-field.spacing.padding.all.field
12
input-field.spacing.gap.horizontal.field
12
input-field.spacing.gap.horizontal.input-indicator
2
input-field.spacing.gap.horizontal.prefix-input
2
input-field.box-shadow.container.active
  • Shadow Color: $core.color.brand.60
  • Shadow Offset:
    • Width: 0
    • Height: 0
  • Shadow Opacity: 1
  • Shadow Radius: 4
input-field.box-shadow.container.error
  • Shadow Color: $core.color.red.120
  • Shadow Offset:
    • Width: 0
    • Height: 0
  • Shadow Opacity: 1
  • Shadow Radius: 4
input-field.box-shadow.container.success
  • Shadow Color: $core.color.green.100
  • Shadow Offset:
    • Width: 0
    • Height: 0
  • Shadow Opacity: 1
  • Shadow Radius: 4

SelectInputMulti Props

V2V1Status
customFiltercustomFilterUnchanged
errorMessageerrorMessageUnchanged
fuseConfigsfuseConfigsUnchanged
hasTitleSeparatorhasTitleSeparatorUnchanged
helpButtonAccessibilityLabelhelpButtonAccessibilityLabelUnchanged
helpContenthelpContentUnchanged
hintTexthintTextUnchanged
isDisabledisDisabledUnchanged
isRequiredisRequiredUnchanged
isSearchableisSearchableUnchanged
labellabelUnchanged
modalTitlemodalTitleUnchanged
onChangeonChangeUnchanged
-onSubmitRemoved
optionsoptionsUnchanged
placeholderplaceholderUnchanged
selectAllselectAllUnchanged
showHintshowHintUnchanged
successMessagesuccessMessageUnchanged
valuevalueUnchanged
Table of Contents