Data Entry

TreeSelect

A select dropdown that renders its options as an expandable tree. Supports single and multiple selection, search, and programmatic expansion.

Single select

Multiple select

Installation

npx benflux-ui add tree-select

Multiple selection

const [selected, setSelected] = useState<string[]>([])

<TreeSelect
  treeData={treeData}
  value={selected}
  onChange={(v) => setSelected(v as string[])}
  multiple
  maxTagCount={3}
  treeDefaultExpandAll
/>

Props

PropTypeDefaultDescription
treeData*TreeSelectNode[]Hierarchical data
valuestring | string[]Controlled selection. String for single, string[] for multiple.
defaultValuestring | string[]Initial selection (uncontrolled)
onChange(value: string | string[]) => voidCalled when selection changes
multiplebooleanfalseEnable multi-select
placeholderstring"Select..."Trigger placeholder
showSearchbooleanfalseShow a search field inside the dropdown
allowClearbooleanfalseShow a clear button
treeDefaultExpandAllbooleanfalseExpand all nodes by default
treeDefaultExpandedKeysstring[][]Keys of nodes to expand initially
maxTagCountnumberMaximum number of tags shown (multiple mode)
disabledbooleanfalseDisable the select
notFoundContentstring"No data"Shown when search finds nothing

TreeSelectNode

interface TreeSelectNode {
  value: string
  label: string
  disabled?: boolean
  children?: TreeSelectNode[]
}