Skip to main content
Version: 2.17.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.
modalAnimationType'none' | 'slide' | 'fade'RN defaultForwarded to the underlying React Native <Modal>. Forced to 'none' when the OS "Reduce Motion" setting is on.
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.
renderChipRemoveIcon(item: T) => ReactElementReplace the built-in glyph on the default chip without reimplementing the whole chip. Ignored when renderSelectedItem is passed.

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, index?: number) => ReactElementFully custom row renderer. The optional index is the row index in the current list (per-section when sections is used) — handy for staggered enter animations. See Animations guide.
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, searchDebounce, inputSearchStyle, searchPlaceholder, searchPlaceholderTextColor, renderInputSearch, renderSearchClearIcon, 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.
renderEmpty(searchText: string) => ReactElement | nullCustom view rendered when the list has no rows — either empty data / sections or a search that filters everything out. The callback receives the current search query so you can switch between "no data" and "no results for X" copy.
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, accessibilityHint, itemAccessibilityLabelField, testID, itemTestIDField, hitSlop. Trigger announces as combobox; items expose role="button" and selected / disabled state. Chips in the selection row carry role="button" plus a "remove from selection" hint, and the chip row is an accessibilityLiveRegion="polite" region so screen readers announce newly-added chips without the user navigating back. See Accessibility for the full picture.

PropTypeDefaultDescription
chipRemoveAccessibilityHintstring'Double tap to remove from selection'Override the accessibilityHint announced on each chip — useful for localization or to describe a non-standard remove gesture.

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.