UNPKG

1.47 kBMarkdownView Raw
1@# Tree
2
3Trees display hierarchical data.
4
5@reactExample TreeExample
6
7@## Props
8
9`Tree` is a stateless component. Its contents are dictated by the `contents` prop, which is an array
10of `ITreeNode`s (see [below](#components/tree.tree-node)). The tree is multi-rooted if
11`contents` contains more than one top-level object.
12
13A variety of interaction callbacks are also exposed as props. All interaction callbacks supply a
14parameter `nodePath`, which is an array of numbers representing a node's position in the tree. For
15example, `[2, 0]` represents the first child (`0`) of the third top-level node (`2`).
16
17@interface ITreeProps
18
19@### Instance methods
20
21* `Tree.getNodeContentElement(nodeId: string | number): HTMLElement | undefined` –
22 Returns the underlying HTML element of the `Tree` node with an id of `nodeId`.
23 This element does not contain the children of the node, only its label and controls.
24 If the node is not currently mounted, `undefined` is returned.
25
26@### Tree node
27
28`ITreeNode` objects determine the contents, appearance, and state of each node in the tree.
29
30For example, `icon` controls the icon displayed for the node, and `isExpanded` determines
31whether the node's children are shown.
32
33@interface ITreeNodeProps
34
35@## CSS
36
37<div class="@ns-callout @ns-intent-primary @ns-icon-info-sign">
38
39Note that the following examples set a maximum width and background color for the tree;
40you may want to do this as well in your own usage.
41
42</div>
43
44@css tree