Skip to main content
Version: 2.15.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[]Flat array of items. Pass sections instead for grouped rendering.
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.

Sections (optional — alternative to data)

PropTypeDescription
sections{ title: string; data: T[] }[]Groups of items rendered under section headers. When provided, data is ignored. See Sectioned lists.
renderSectionHeader(section) => ReactElement | nullFully custom header renderer.
sectionHeaderStyleViewStyleStyle for the default header container.
sectionHeaderTextStyleTextStyleStyle for the default header <Text>.

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.
activeItemTextStyleTextStyleExtra text style applied only to selected rows.
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.
hideSelectedFromListbooleanfalseHide already-selected items from the rendered list.
selectedToTopbooleanfalseSort selected items to the top of the list (no-op when hideSelectedFromList is true). See Selected-item ordering.

Same props as Dropdown: search, searchField (supports keyof T or (keyof T)[]), searchQuery, searchKeyboardType, searchInputProps, persistSearch, inputSearchStyle, searchPlaceholder, searchPlaceholderTextColor, renderInputSearch, onChangeText.

Icons & modal header

Same as Dropdown: iconStyle, iconColor, renderLeftIcon, renderRightIcon. MultiSelect also accepts:

PropTypeDescription
renderModalHeader(close: () => void) => ReactElement | nullRenders a header view above the list inside the modal. See Modal header.

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.
closeModalWhenSelectedItembooleanfalseWhen true, the list closes after each toggle. Defaults to false to match typical multi-select UX (keep selecting).
showsVerticalScrollIndicatorbooleantrueScroll indicator on the list.
flatListPropsOmit<FlatListProps<T>, 'renderItem' | 'data'>Passthrough to the underlying FlatList.
onEndReached() => voidFires when the list scrolls within onEndReachedThreshold of the bottom. See Pagination.
onEndReachedThresholdnumber0.5Distance from the end (in viewport units) at which onEndReached fires.
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.