React Native MantineInputs

TreeSelect

Pick one or more values from a hierarchical data set

Import: import { TreeSelect } from 'react-native-mantine';

Usage

import { TreeSelect } from 'react-native-mantine';
import type { TreeNodeData } from 'react-native-mantine';

const data: TreeNodeData[] = [
  {
    value: 'frontend',
    label: 'Frontend',
    children: [
      { value: 'react', label: 'React' },
      { value: 'vue', label: 'Vue' },
    ],
  },
];

// Single mode
<TreeSelect
  label="Technology"
  placeholder="Pick one technology"
  data={data}
  value={value}
  onChange={setValue}
  searchable
  clearable
/>

// Checkbox mode, parent checks all leaves
<TreeSelect
  data={data}
  mode="checkbox"
  defaultExpandAll
  maxDisplayedValues={2}
/>

Props

PropTypeDefaultDescription
data (required)TreeNodeData[]Tree data with label, value and optional children
mode'single' | 'multiple' | 'checkbox'"single"Selection mode, in checkbox mode checking a parent checks all of its leaf nodes
valuestring | string[] | nullControlled value: string or null for single mode, string[] for multiple and checkbox modes
defaultValuestring | string[] | nullDefault value for uncontrolled component
onChange(value: string | string[] | null) => voidCalled when value changes
allowDeselectbooleantrueIn single mode, determines whether pressing the selected node deselects it
maxValuesnumberMaximum number of selected values in multiple and checkbox modes
maxDisplayedValuesnumberMaximum number of values displayed in the input, the rest is shown as +N
defaultExpandedValuesstring[]Node values that are expanded by default
defaultExpandAllbooleanfalseDetermines whether all nodes should be expanded by default
searchablebooleanfalseDetermines whether the search input should be displayed in the dropdown
searchPlaceholderstring"Search..."Search input placeholder
nothingFoundMessageReact.ReactNodeMessage displayed when no nodes match the search
clearablebooleanfalseDetermines whether the clear option should be displayed
clearButtonLabelstring"Clear"Clear option label
onClear() => voidCalled when the value is cleared
labelReact.ReactNodeInput label
descriptionReact.ReactNodeInput description
errorReact.ReactNodeError message
placeholderstringInput placeholder
size'xs' | 'sm' | 'md' | 'lg' | 'xl'"sm"Controls input height and font size
radiusMantineNumberSize"sm"Key of theme.radius or any valid value to set border-radius
requiredbooleanDisplays required asterisk
disabledbooleanIf set, the input is disabled
maxDropdownHeightnumber400Maximum height of the dropdown list

Source on GitHub · npm