React Native · Components
TreeSelect
A select box picking from a tree (same API as the web TreeSelect): nested options such as categories, departments, folders.
4 exports
Live example
The preview runs in the browser with the web component; the native component takes the same props and looks the same on iOS and Android.
Preview
Code
Events
- Events appear here when you interact with the preview.
In a form
Import
TreeSelect
componentA select box picking from a tree (same API as the web TreeSelect): nested options such as categories, departments, folders. Tapping the box opens a TreeView; on phones it is a bottom sheet.
- Single selection: tapping a node selects it and closes; with
leavesOnlyonly leaves. WithshowPaththe full path in the box. - Multiple selection: checkboxes with
multiple; a parent is linked to its children (tri-state). The value holds leaves, fully selected branches or all of them. - Search: a search box with more than 15 nodes; non-matching branches are hidden.
- Large trees: rows are virtualized; with
loadChildrenbranches load as they expand. - Form: binds inside a
Formvianame.
Examples
SingleTreeSelectProps
interfaceSingle selection TreeSelect.
Extends: FieldProps
| Name | Type | Default | Description |
|---|---|---|---|
multiple? | false | false | When true, multiple nodes are selected with checkboxes. |
value? | string | Selected id in controlled use; "" for none. | |
defaultValue? | string | Initial value in uncontrolled use. | |
onValueChange? | (value: string, node: TreeNode<T> | undefined) => void | With the id and node when the selection changes ("" when cleared). | |
leavesOnly? | boolean | false | Only leaves can be selected; tapping a parent node toggles it. |
items | readonly TreeNode<T>[] | Nodes; children can be loaded later with loadChildren. | |
loadChildren? | (node: TreeNode<T>, context: { signal: AbortSignal; }) => Promise<readonly TreeNode<T>[] | undefined | void> | hasChildren nodes fetch their children when expanded. | |
search? | boolean | "auto" | "auto" | Search box in the panel; "auto": with more than 15 nodes. |
placeholder? | string | "Seçiniz" | Text shown when nothing is selected. |
defaultExpanded? | readonly string[] | "all" | Initially expanded nodes; "all" for all. If omitted the paths of the selected nodes expand. | |
icon? | IconProp | Icon at the start of the box. | |
clearable? | boolean | false | Clear button. |
showPath? | boolean | false | Show the selection's path in the box too ("Türkiye / İstanbul / Kadıköy")? |
pathSeparator? | string | " / " | showPath separator. |
variant? | FieldVariant | "outline" | Field appearance. |
open? | boolean | Is the panel open, in controlled use? | |
onOpenChange? | (open: boolean) => void | When the panel opens or closes. | |
aria-label? | string | Screen reader name; give it when there is no visible label. | |
style? | StyleProp<ViewStyle> | Container style. |
MultiTreeSelectProps
interfaceMultiple selection TreeSelect.
Extends: FieldProps
| Name | Type | Default | Description |
|---|---|---|---|
multiple | true | Multiple nodes are selected with checkboxes; the panel does not close on selection. | |
value? | readonly string[] | Checked ids in controlled use (see checkOutput). | |
defaultValue? | readonly string[] | Initial values in uncontrolled use. | |
onValueChange? | (value: string[], nodes: TreeNode<T>[]) => void | With the ids and nodes when the selection changes. | |
checkOutput? | CheckOutput | "leaves" | Which nodes go into the value? See CheckOutput. |
checkMode? | "cascade" | "independent" | "cascade" | "cascade": a parent is linked to its children (tri-state); "independent". |
maxDisplay? | number | 2 | Maximum names written in the box; the rest become "+3". |
items | readonly TreeNode<T>[] | Nodes; children can be loaded later with loadChildren. | |
loadChildren? | (node: TreeNode<T>, context: { signal: AbortSignal; }) => Promise<readonly TreeNode<T>[] | undefined | void> | hasChildren nodes fetch their children when expanded. | |
search? | boolean | "auto" | "auto" | Search box in the panel; "auto": with more than 15 nodes. |
placeholder? | string | "Seçiniz" | Text shown when nothing is selected. |
defaultExpanded? | readonly string[] | "all" | Initially expanded nodes; "all" for all. If omitted the paths of the selected nodes expand. | |
icon? | IconProp | Icon at the start of the box. | |
clearable? | boolean | false | Clear button. |
showPath? | boolean | false | Show the selection's path in the box too ("Türkiye / İstanbul / Kadıköy")? |
pathSeparator? | string | " / " | showPath separator. |
variant? | FieldVariant | "outline" | Field appearance. |
open? | boolean | Is the panel open, in controlled use? | |
onOpenChange? | (open: boolean) => void | When the panel opens or closes. | |
aria-label? | string | Screen reader name; give it when there is no visible label. | |
style? | StyleProp<ViewStyle> | Container style. |
TreeSelectProps
typeTreeSelect props (same names as web).
Extends: FieldProps
| Name | Type | Default | Description |
|---|---|---|---|
multiple? | false | true | false | When true, multiple nodes are selected with checkboxes. |
value? | string | readonly string[] | Selected id in controlled use; "" for none. | |
defaultValue? | string | readonly string[] | Initial value in uncontrolled use. | |
onValueChange? | (value: string, node: TreeNode<T> | undefined) => void | (value: string[], nodes: TreeNode<T>[]) => void | With the id and node when the selection changes ("" when cleared). | |
leavesOnly? | boolean | false | Only leaves can be selected; tapping a parent node toggles it.(SingleTreeSelectProps<T>) |
items | readonly TreeNode<T>[] | Nodes; children can be loaded later with loadChildren. | |
loadChildren? | (node: TreeNode<T>, context: { signal: AbortSignal; }) => Promise<readonly TreeNode<T>[] | undefined | void> | hasChildren nodes fetch their children when expanded. | |
search? | boolean | "auto" | "auto" | Search box in the panel; "auto": with more than 15 nodes. |
placeholder? | string | "Seçiniz" | Text shown when nothing is selected. |
defaultExpanded? | readonly string[] | "all" | Initially expanded nodes; "all" for all. If omitted the paths of the selected nodes expand. | |
icon? | IconProp | Icon at the start of the box. | |
clearable? | boolean | false | Clear button. |
showPath? | boolean | false | Show the selection's path in the box too ("Türkiye / İstanbul / Kadıköy")? |
pathSeparator? | string | " / " | showPath separator. |
variant? | FieldVariant | "outline" | Field appearance. |
open? | boolean | Is the panel open, in controlled use? | |
onOpenChange? | (open: boolean) => void | When the panel opens or closes. | |
aria-label? | string | Screen reader name; give it when there is no visible label. | |
style? | StyleProp<ViewStyle> | Container style. | |
checkOutput? | CheckOutput | "leaves" | Which nodes go into the value? See CheckOutput.(MultiTreeSelectProps<T>) |
checkMode? | "cascade" | "independent" | "cascade" | "cascade": a parent is linked to its children (tri-state); "independent".(MultiTreeSelectProps<T>) |
maxDisplay? | number | 2 | Maximum names written in the box; the rest become "+3".(MultiTreeSelectProps<T>) |