Skip to main content
Version: 2.13.0

MultiSelect

Multi-select variant. The user taps the trigger, toggles one or more items, and the selection renders as a row of chips either below or inside the trigger.

Minimal example

import { useState } from 'react';
import { MultiSelect } from '@carlos3g/element-dropdown';

const data = [
{ label: 'Apple', value: 'apple' },
{ label: 'Banana', value: 'banana' },
{ label: 'Cherry', value: 'cherry' },
];

export function FruitBasket() {
const [value, setValue] = useState<string[]>([]);
return (
<MultiSelect
data={data}
labelField="label"
valueField="value"
placeholder="Pick fruits"
value={value}
onChange={setValue}
/>
);
}

MultiSelect is controlled. value is the array of selected valueField values; onChange fires with the new array every time an item is toggled.

Props

Required

PropTypeDescription
dataT[]Array of items to render.
labelFieldkeyof TField on each item used as the visible label.
valueFieldkeyof TField on each item that identifies it uniquely.
valuestring[] | nullCurrently selected valueField values.
onChange(value: string[]) => voidFires with the new selection array.

Display

PropTypeDefaultDescription
placeholderstring'Select item'Trigger label when nothing is selected.
placeholderStyleTextStyleStyle for the placeholder text.
selectedTextStyleTextStyleStyle for the trigger label when the selection is non-empty.
selectedTextPropsTextProps{}Extra props for the trigger <Text>.
maxSelectnumberCap on how many items can be selected.
visibleSelectedItembooleantrueWhen false, hides the chip row below the trigger.
alwaysRenderSelectedItembooleanfalseWhen true, the chip row stays visible while the list is open.
insidebooleanfalseRender selected chips inside the trigger instead of below it. See Inside mode.

Container and layout

PropTypeDefaultDescription
styleViewStyleStyle for the outer wrapper.
containerStyleViewStyleStyle for the floating list container.
backgroundColorstringScrim color behind the modal in full-screen modes.
maxHeightnumber340Max list height.
minHeightnumber0Min list height.
mode'default' | 'modal' | 'auto''default'See the matching Dropdown prop.
dropdownPosition'auto' | 'top' | 'bottom''auto'Force list above or below.
invertedbooleantrueReverses scroll when list opens above.
isInsideModalbooleanfalseSet when inside a React Native <Modal>.

Selected chips

PropTypeDescription
selectedStyleViewStyleStyle for each chip container.
renderSelectedItem(item: T, unSelect?: (item: T) => void) => ReactElementFully custom chip renderer.

Items

PropTypeDefaultDescription
itemContainerStyleViewStyleStyle merged on top of the built-in row style.
itemTextStyleTextStyleStyle for the default item label.
activeColorstring'#F6F7F8'Background of the row for already-selected items.
renderItem(item: T, selected?: boolean) => ReactElementFully custom row renderer.
disabledFieldkeyof TMarks individual items as non-interactive.

Same props as Dropdown: search, searchField, searchQuery, inputSearchStyle, searchPlaceholder, searchPlaceholderTextColor, renderInputSearch, onChangeText.

Icons

Same as Dropdown: iconStyle, iconColor, renderLeftIcon, renderRightIcon.

Behavior

PropTypeDefaultDescription
disablebooleanfalseDisable the trigger.
keyboardAvoidingbooleantrueLift the list when the keyboard opens.
confirmSelectItembooleanfalseCall onConfirmSelectItem on toggles instead of immediately mutating value.
confirmUnSelectItembooleanfalseSame but for un-toggling.
onConfirmSelectItem(item: T) => voidConfirm handler.
showsVerticalScrollIndicatorbooleantrueScroll indicator on the list.
flatListPropsOmit<FlatListProps<T>, 'renderItem' | 'data'>Passthrough to the underlying FlatList.
excludeItemsT[][]Items to hide from the list.
excludeSearchItemsT[][]Items shown in the list but excluded from search.

Callbacks

PropTypeDescription
onFocus() => voidFires when the list opens.
onBlur() => voidFires when the list closes.

Text rendering

PropTypeDescription
fontFamilystringPropagated to all text.
allowFontScalingbooleanPropagated to every Text/TextInput.

Accessibility

Same props as Dropdown: accessibilityLabel, itemAccessibilityLabelField, testID, itemTestIDField, hitSlop. Trigger announces as combobox; items expose selected / disabled state.

Imperative ref

import { useRef } from 'react';
import { MultiSelect } from '@carlos3g/element-dropdown';
import type { IMultiSelectRef } from '@carlos3g/element-dropdown';

const ref = useRef<IMultiSelectRef>(null);

<MultiSelect ref={ref} {/* … */} />

ref.current?.open() and ref.current?.close() mirror the Dropdown API.