Gathering detailed insights and metrics for react-native-tree-multi-select
Gathering detailed insights and metrics for react-native-tree-multi-select
Gathering detailed insights and metrics for react-native-tree-multi-select
Gathering detailed insights and metrics for react-native-tree-multi-select
Super-fast tree view with multi-selection capabilities, using checkboxes and search filtering.
npm install react-native-tree-multi-select
Typescript
Module System
Min. Node Version
Node Version
NPM Version
45.5
Supply Chain
35.6
Quality
81.2
Maintenance
50
Vulnerability
94.1
License
TypeScript (91.23%)
Java (3.98%)
JavaScript (1.6%)
Ruby (1.39%)
Objective-C (1.28%)
Objective-C++ (0.42%)
C (0.06%)
Swift (0.04%)
Total Downloads
13,316
Last Day
50
Last Week
308
Last Month
1,286
Last Year
10,591
MIT License
84 Stars
452 Commits
6 Forks
2 Watchers
11 Branches
5 Contributors
Updated on May 04, 2025
Minified
Minified + Gzipped
Latest Version
1.9.4
Package Id
react-native-tree-multi-select@1.9.4
Unpacked Size
291.68 kB
Size
58.93 kB
File Count
152
NPM Version
10.9.2
Node Version
22.14.0
Published on
Apr 04, 2025
Cumulative downloads
Total Downloads
Last Day
177.8%
50
Compared to previous day
Last Week
13.2%
308
Compared to previous week
Last Month
4%
1,286
Compared to previous month
Last Year
288.7%
10,591
Compared to previous year
3
35
⚡️Super-fast Tree view with multi-selection capabilities, using checkboxes and search filtering.
Using yarn:
1yarn add react-native-tree-multi-select
using npm:
1npm install react-native-tree-multi-select
Dependencies that need to be installed for this library to work:
Make sure to follow the native-related installation instructions for these dependencies.
1import { 2 TreeView, 3 type TreeNode, 4 type TreeViewRef 5} from 'react-native-tree-multi-select'; 6 7// Refer to the Properties table below or the example app for the TreeNode type 8const myData: TreeNode[] = [...]; 9 10export function TreeViewUsageExample(){ 11 const treeViewRef = React.useRef<TreeViewRef | null>(null); 12 13 // It's recommended to use debounce for the search function (refer to the example app) 14 function triggerSearch(text: string){ 15 // Pass search text to the tree along with the keys on which search is to be done(optional) 16 treeViewRef.current?.setSearchText(text, ["name"]); 17 } 18 19 // Callback functions for check and expand state changes: 20 const handleSelectionChange = ( 21 _checkedIds: string[], 22 _indeterminateIds: string[] 23 ) => { 24 // NOTE: Handle _checkedIds and _indeterminateIds here 25 }; 26 const handleExpanded = (expandedIds: string[]) => { 27 // NOTE: Do something with updated expandedIds here 28 }; 29 30 // Expand collapse calls using ref 31 const expandAllPress = () => treeViewRef.current?.expandAll?.(); 32 const collapseAllPress = () => treeViewRef.current?.collapseAll?.(); 33 const expandNodes = (idsToExpand: string[]) => treeViewRef.current?.expandNodes?.( 34 idsToExpand 35 ); 36 const collapseNodes = (idsToCollapse: string[]) => treeViewRef.current?.collapseNodes?.( 37 idsToCollapse 38 ); 39 40 // Multi-selection function calls using ref 41 const onSelectAllPress = () => treeViewRef.current?.selectAll?.(); 42 const onUnselectAllPress = () => treeViewRef.current?.unselectAll?.(); 43 const onSelectAllFilteredPress = () => treeViewRef.current?.selectAllFiltered?.(); 44 const onUnselectAllFilteredPress = () => treeViewRef.current?.unselectAllFiltered?.(); 45 const selectNodes = (idsToExpand: string[]) => treeViewRef.current?.selectNodes?.( 46 idsToSelect 47 ); 48 const unselectNodes = (idsToCollapse: string[]) => treeViewRef.current?.unselectNodes?.( 49 idsToUnselect 50 ); 51 52 return( 53 // ... Remember to keep a fixed height for the parent. Read Flash List docs to know why 54 <TreeView 55 ref={treeViewRef} 56 data={myData} 57 onCheck={handleSelectionChange} 58 onExpand={handleExpanded} 59 /> 60 ); 61}
<ID = string>
The TreeViewProps
interface defines the properties for the tree view component.
Property | Type | Required | Description |
---|---|---|---|
data | TreeNode<ID = string>[] | Yes | An array of TreeNode objects |
onCheck | (checkedIds: ID[], indeterminateIds: ID[]) => void | No | Callback when a checkbox state changes |
onExpand | (expandedIds: ID[]) => void | No | Callback when a node is expanded |
preselectedIds | ID[] | No | An array of id s that should be pre-selected |
preExpandedIds | ID[] | No | An array of id s that should be pre-expanded |
selectionPropagation | SelectionPropagation | No | Control Selection Propagation Behavior. Choose whether you want to auto-select children or parents. |
initialScrollNodeID | ID | No | Set node ID to scroll to intiially on tree view render. |
indentationMultiplier | number | No | Indentation (marginStart ) per level (defaults to 15) |
treeFlashListProps | TreeFlatListProps | No | Props for the flash list |
checkBoxViewStyleProps | BuiltInCheckBoxViewStyleProps | No | Props for the checkbox view |
CheckboxComponent | ComponentType< CheckBoxViewProps> | No | A custom checkbox component. Defaults to React Native Paper's Checkbox |
ExpandCollapseIconComponent | ComponentType< ExpandIconProps> | No | A custom expand/collapse icon component |
ExpandCollapseTouchableComponent | ComponentType< TouchableOpacityProps> | No | A custom expand/collapse touchable component |
CustomNodeRowComponent | React.ComponentType< NodeRowProps<ID>> | No | Custom row item component |
ID
type parameter allows flexibility in specifying the type of node identifiers (e.g., string
, number
, or custom types).CustomNodeRowComponent
is provided then below props are not applied:
indentationMultiplier
checkBoxViewStyleProps
CheckboxComponent
BuiltInCheckBoxViewStyleProps
ExpandCollapseIconComponent
ExpandCollapseTouchableComponent
.renderScrollComponent
value in treeFlashListProps
to ScrollView
from react-native-gesture-handler
.<ID = string>
The TreeNode
interface defines the properties for individual item of the tree view
Property | Type | Required | Description |
---|---|---|---|
id | ID (default: string ) | Yes | Unique identifier for the node |
name | string | Yes | The display name of the node |
children | TreeNode<ID>[] | No | An array of child TreeNode<ID> objects |
[key: string] | any | No | Any additional properties for the node (May be useful to perform search on) |
<ID = string>
The TreeViewRef
interface defines the properties for the ref object of the tree view component
Property | Type | Description |
---|---|---|
selectAll | () => void | Selects all nodes |
unselectAll | () => void | Unselects all nodes |
selectAllFiltered | () => void | Selects all filtered nodes |
unselectAllFiltered | () => void | Unselects all filtered nodes |
expandAll | () => void | Expands all nodes |
collapseAll | () => void | Collapses all nodes |
expandNodes | (ids: ID[]) => void | Expands specified nodes |
collapseNodes | (ids: ID[]) => void | Collapses specified nodes |
selectNodes | (ids: ID[]) => void | Selects specified nodes |
unSelectNodes | (ids: ID[]) => void | Unselects specified nodes |
setSearchText | (searchText: string, searchKeys?: string[]) => void | Set the search text and optionally the search keys. Default search key is "name" Recommended to call this inside a debounced function if you find any performance issue otherwise. |
scrollToNodeID | (params: ScrollToNodeParams<ID>) => void; | Scrolls the tree view to the node of the specified ID. |
getChildToParentMap | () => Map<ID, ID> | Get the child to parent tree view map. |
Property | Type | Required | Description |
---|---|---|---|
nodeId | ID | Yes | Node ID to expand and scroll to. |
expandScrolledNode | boolean | No | Whether to expand scrolled node to reveal its children. Defaults to false . |
animated | boolean | No | Control if scrolling should be animated. |
viewOffset | number | No | A fixed number of pixels to offset the scrolled node position. |
viewPosition | number | No | A value of 0 places the scrolled node item at the top, 1 at the bottom, and 0.5 centered in the middle. |
The SelectionPropagation
interface defines the selection propagation behaviour of the tree view
Property | Type | Required | Description |
---|---|---|---|
toChildren | boolean | No | Whether to propagate selection to children nodes. Defaults to true . |
toParents | boolean | No | Whether to propagate selection to parent nodes. Defaults to true . |
All properties of FlashListProps
(from @shopify/flash-list
) except for data
and renderItem
This interface allows you to customize the style of the built-in checkbox component that is rendered in the tree view by default. Overriden if CustomNodeRowComponent
is used.
Property | Type | Required | Description |
---|---|---|---|
outermostParentViewStyle | StyleProp<ViewStyle> | No | Optional style modifier for the outermost parent view. |
checkboxParentViewStyle | StyleProp<ViewStyle> | No | Optional style modifier for the checkbox parent view. |
textTouchableStyle | StyleProp<ViewStyle> | No | Optional style modifier for the text touchable style. |
checkboxProps | CheckboxProps | No | Optional props for the checkbox component. |
textProps | TextProps (React Native) | No | Optional props for the text component. |
All properties of RNPaperCheckboxAndroidProps
(from react-native-paper
) except for onPress
and status
Property | Type | Required | Description |
---|---|---|---|
value | CheckboxValueType | Yes | The current value of the checkbox |
onValueChange | (value: boolean) => void | Yes | Function to be called when the checkbox is pressed |
text | string | Yes | The display text besides the checkbox |
Type: boolean
OR "indeterminate"
Property | Type | Required | Description |
---|---|---|---|
isExpanded | boolean | Yes | Indicates if the icon is expanded |
<ID = string>
Property | Type | Required | Description |
---|---|---|---|
node | TreeNode | Yes | The node to be rendered |
level | number | Yes | The depth of the node in the tree |
checkedValue | CheckboxValueType | Yes | The current value of the checkbox |
isExpanded | boolean | Yes | Whether the node is expanded or not |
onCheck | () => void | Yes | Function to be called when the checkbox is pressed |
onExpand | () => void | Yes | Function to be called when the expand button is pressed |
selectionPropagation
prop 🎉If you do not see what you want in the planned feature list, raise a feature request.
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT
No vulnerabilities found.
No security vulnerabilities found.