Tree view
EuiTreeView allows you to render recursive objects, such as a file directory. It is not meant to be used as primary navigation, for that we recommend using EuiSideNav.
EuiTreeView does not accept children
directly but requires an array of EuiTreeViewNode
s through its items
prop.
Each node requires a label
and a unique id
. The icon
prop accepts any icon or token. You can also specify a different icon for the open state with the iconWhenExpanded
prop. Use the nodes' children
prop to nest more nodes.
Provide a descriptive aria-label
for each tree view. This component also builds in keyboard navigation allowing users to traverse the tree using the arrow keys, spacebar, and return.
Optional styling
EuiTreeView supports a compressed mode with the display="compressed"
setting. When using the compressed version it's highly recommended to use the small size of EuiIcon and the extra small size of EuiToken. This will help prevent awkard alignment issues when used alongside the showExpansionArrows
prop.
The showExpansionArrows
prop provides an additional visual indicator. Ideal for when a tree's items use icons that don't immediately let a user know that there are nested nodes that may not be visible.
In some cases, you may want to automatically expand all the items with children. In those instances, you can use the expandByDefault
prop, as seen in the example below.
Lastly, each node can also accept a custom className
should you need to style them individually.
Props
EuiTreeView
Prop | Description and type | Default value |
---|---|---|
Prop items# | Description and type An array of EuiTreeViewNodes Node[] | Default value Required |
Prop children# | Description and type Never accepts children directly, only through the never | Default value |
Prop className# | Description and type Type: string | Default value |
Prop css# | Description and type Type: Interpolation<Theme> | Default value |
Prop data-test-subj# | Description and type Type: string | Default value |
Prop display# | Description and type Optionally use a variation with smaller text and icon sizes EuiTreeViewDisplayOptions | Default value default |
Prop expandByDefault# | Description and type Set all items to open on initial load boolean | Default value |
Prop showExpansionArrows# | Description and type Display expansion arrows next to all items boolean | Default value |
Prop ref# | Description and type Allows getting a ref to the component instance. LegacyRef<unknown> | Default value |
EuiTreeViewItem
Prop | Description and type | Default value |
---|---|---|
Prop id# | Description and type Required for string | Default value Required |
Prop label# | Description and type The main button content ReactNode | Default value Required |
Prop className# | Description and type Type: string | Default value |
Prop aria-label# | Description and type Defines a string value that labels the current element. string | Default value |
Prop data-test-subj# | Description and type Type: string | Default value |
Prop css# | Description and type Type: Interpolation<Theme> | Default value |
Prop children# | Description and type Used to render nested ReactNode | Default value |
Prop icon# | Description and type Optional icon to render. Pass, e.g., ReactNode | Default value |
Prop hasArrow# | Description and type Renders an arrow if boolean | Default value |
Prop isActive# | Description and type Adds a targetable modifier class boolean | Default value |
Prop isExpanded# | Description and type Sets the boolean | Default value |
Prop display# | Description and type Determines default or compressed display EuiTreeViewDisplayOptions | Default value |
Prop buttonRef# | Description and type Type: Ref<HTMLButtonElement> | Default value |
Prop wrapperProps# | Description and type Optional extra props to pass to the wrapping HTMLAttributes<HTMLLIElement> | Default value |