TreeList

The records of the ambient <List> as a collapsible tree, nested by a parent field. Give the list a perPage that covers the whole tree: a record whose parent is on another page shows as a root.

Installation

pnpm dlx shadcn@latest add @chelone/tree-list

The records of the ambient <List> as a collapsible tree, nested by a parent field. Give the list a perPage that covers the whole tree: a record whose parent is on another page shows as a root.

Props

PropTypeDefaultDescription
classNamestring—
defaultExpandedboolean—Whether branches start open. Default `false`.
emptyReactNode—Rendered with no records, in place of `ListNoResults`.
iconMapRecord<string, ComponentType<{ className?: string }>>—
iconSourcestring—The field whose value picks a component from `iconMap`.
linkTypefalse | "show" | "edit"—Where a row links to when `onSelect` is not given. `edit` by default, `show` when the resource has no edit view, and an inert row when it has neither. `false` leaves rows inert.
loadingReactNode—Rendered while the list is pending, in place of `SimpleListLoading`.
onSelect(record: LooseRecord) => void—Called with the record when a row is selected, in place of navigating.
parentSourcestring—The field holding the parent's id; a dotted path reads a nested value.
titleSourcestring—The string field shown as the row title; the record representation otherwise.