Dark Light
System
Default LBBW Jira Confluence Source Code
Share
Playground

Tree View

<afp-tree-view> Since 1.2.0 experimental This component uses the light DOM, so its markup and styles are part of the regular document flow.

A tree view component for displaying hierarchical data with expandable/collapsible nodes.

Examples #

Basic Tree View #

Use the data property to provide the tree structure. Each node must have an id and label.

With Icons #

Add icons to tree nodes using the icon property.

Sizes #

Use the size attribute to change a tree view's size.

Default Expansion #

Use expanded boolean in the data to have that node open by default when the tree first renders.

Multi-Select #

Use the multiSelect attribute to enable selecting multiple nodes.

Disabled Nodes #

Use the disabled property on individual nodes to disable them.

Disabled Tree View #

Use the disabled attribute to disable the entire tree view.

Selection Events #

Use the afp-select event to listen for single node selections.

Programmatic Control #

Use the public methods to control the tree view programmatically.

Expand All Collapse All Select First Clear Selection

Custom Data #

Use the data property on nodes to store custom data.

Deep Nesting #

The tree view supports unlimited nesting levels.

Properties

Learn more about properties.

Name Description Reflects
size
size of the tree view.
Type
AfpSize
Name Description
SMALL
Small size with compact dimensions.
MEDIUM
Medium size with standard dimensions.
LARGE
Large size with expanded dimensions.
AfpSize
Default AfpSize.MEDIUM
data
tree data structure
Type AfpTreeNode[]
Default []
multiSelect
multiselect
enable multi-selection
Type boolean
Default false
selectedIds
selectedids
selected node IDs
Type string[]
Default []
disabled
disabled state of the tree view
Type boolean
Default false

Methods

Learn more about using methods.

Name Description Arguments
expandNode
This method expands a node by its ID. It can be used to programmatically expand a node without user interaction.
nodeId<string>
collapseNode
This method collapses a node by its ID. It can be used to programmatically collapse a node without user interaction.
nodeId<string>
expandAll
This method expands all nodes in the tree. It can be used to programmatically expand all nodes without user interaction.
-
collapseAll
This method collapses all nodes in the tree. It can be used to programmatically collapse all nodes without user interaction.
-
selectNode
This method selects a node by its ID. It can be used to programmatically select a node without user interaction.
nodeId<string>
deselectNode
This method deselects a node by its ID.
nodeId<string>
clearSelection
This method clears all selections in the tree.
-

Events

Learn more about events.

Name Return Description
afp-select AfpTreeNode
Emitted when a node is selected.
afp-change AfpTreeNode[]
Emitted when the selection changes.

CSS Parts

Learn more about CSS Parts.

Name Description Selector
base
The component's base wrapper.
::part(base)
tree
The tree container element.
::part(tree)
node
A tree node container.
::part(node)
node-content
The content wrapper of a node.
::part(node-content)
node-toggle
The toggle button for expanding/collapsing.
::part(node-toggle)
toggle-icon
The chevron icon for toggle.
::part(toggle-icon)
node-checkbox
The checkbox element shown in multi-select mode.
::part(node-checkbox)
node-icon
The icon of a node.
::part(node-icon)
node-label
The label text of a node.
::part(node-label)
children
The children container of a node.
::part(children)

CSS Custom Properties

Name Description Default
--afp-tree-view-disabled-opacity
The opacity of the tree view when disabled.
0.5

Dependencies

The component automatically brings in the listed items, including any nested dependencies that may exist.

afp-icon afp-checkbox

Importing

Using the bundle is the recommended method to include components. If you’d rather handle imports manually, you can use the code examples below.

import '@afp-design-system/core/dist/components/tree-view/tree-view.js';
Share
Create a link with a predefined theme that is automatically applied when the generated link is opened. Default LBBW Presentation Mode
Abort Copy Link