Knit UI
GitHub

Playground

Loading playground…

true
false
false
Playground
<Tree
  data={[{ value: "fruits", label: "Fruits", children: [{ value: "apple", label: "Apple" }, { value: "banana", label: "Banana" }, { value: "cherry", label: "Cherry" }] }, { value: "vegetables", label: "Vegetables", children: [{ value: "carrot", label: "Carrot" }, { value: "broccoli", label: "Broccoli" }] }, { value: "dairy", label: "Dairy" }]}
  expandOnClick
  selectOnClick={false}
  withLines={false}
  levelOffset="$lg"
/>

Examples

Shadows

The shadow elevation prop, inherited from Box, across all token levels.

Loading example…

ShadowsSourceStorybook

With Lines

Connecting guide lines drawn along each subtree indent.

Loading example…

With LinesSourceStorybook

Select On Click

Nodes become selectable on press; the selected row is visually highlighted.

Loading example…

Select On ClickSourceStorybook

Deep Level Offset

Deeper nesting offset makes hierarchy levels easier to distinguish.

Loading example…

Deep Level OffsetSourceStorybook

Custom Render Node

Custom node renderer via renderNode — each row gets a file-type icon derived from the node value, with the expand chevron driven manually via elementProps.

Loading example…

Custom Render NodeSourceStorybook

Controlled With Actions

Controlled tree using an external useTree controller — expand-all and collapse-all buttons drive the tree from outside the component.

Loading example…

Controlled With ActionsSourceStorybook

Pre Expanded

Pre-expanded tree — the src subtree is open on first render using getTreeExpandedState passed to useTree.

Loading example…

Pre ExpandedSourceStorybook

Checked Nodes

Checkable nodes — a Checkbox per row driven by the useTree controller. checkNode/uncheckNode cascade to descendants, and parents render the partial isNodeIndeterminate state automatically.

Loading example…

Checked NodesSourceStorybook

Multiple Selection

Multiple selection — useTree({ multiple: true }) lets several nodes be selected at once (Ctrl/Cmd-click semantics), instead of the default single selection.

Loading example…

Multiple SelectionSourceStorybook

Styles

Per-slot styles targets individual parts — here the label and chevron.

Loading example…

StylesSourceStorybook

Props

PropTypeDefaultDescription
data requiredTreeNodeData[]Hierarchical data used to render the tree.
checkOnSpaceboolean | undefinedfalseAccepted for Mantine parity. Space-to-check is a web-only keyboard behaviour; drive checking via the controller (`checkNode`) from a `renderNode` `Checkbox.Indicator` for cross-platform support.
clearSelectionOnOutsideClickboolean | undefinedfalseAccepted for Mantine parity. Clearing selection on outside click relies on DOM click-outside detection (web-only); deferred.
disabled systemboolean | undefined
expandOnClickboolean | undefinedtrueExpand/collapse a branch when its row is pressed.
expandOnSpaceboolean | undefinedtrueAccepted for Mantine parity. Space-to-expand is a web-only keyboard behaviour (no cross-platform key primitive); on native, press to expand.
levelOffsetnumber | GetThemeValueForKey<"paddingLeft"> | Animated.AnimatedNode | "safe" | null | undefined
$xxs · $xs · $sm · $md · $lg · $xl · $xxl
"$lg"Horizontal indent added per nesting level.
renderNodeRenderNode | undefinedRender a fully custom node row from the `RenderTreeNodePayload`. Retained as the ultimate dynamic escape hatch over the composable `Tree.Node`/`Tree.Row` parts — when set it replaces each row wholesale.
selectOnClickboolean | undefinedfalseSelect a node when its row is pressed.
shadow system"xs" | "sm" | "md" | "lg" | "xl" | "xxs" | "xxl" | undefined
styles systemSlotStyles<TreeStyles> | undefinedPer-slot style sugar — props spread onto the matching part.
theme systemThemeName | null | undefinedApplies a theme to this element
treeTreeController | undefinedExternal controller from `useTree`; an internal one is created when omitted.
withLinesboolean | undefinedfalseRender connecting guide lines along each subtree.

Style slots

Every part of Tree can be styled through the styles prop. Explicit props on the component always win over slot styles.

SlotUsage
chevronstyles={{ chevron: { … } }}
labelstyles={{ label: { … } }}
nodestyles={{ node: { … } }}
rootstyles={{ root: { … } }}
rowstyles={{ row: { … } }}
subtreestyles={{ subtree: { … } }}
Accessibility & DOM props (2)
PropType
keyKey | null | undefined
refRef<TamaguiElement> | undefined

Plus 498 inherited style props from Box — the full Tamagui/React Native style surface, including token shorthands like p, mx, bg and c. See Tokens for the scales they accept, or the full list.