Tree view
Angular Bootstrap 5 Tree view plugin
MDB treeview plugin is used to show hierarchical information which starts from the root item and proceed to its children and their respective children. Each item besides the root has a parent and can have children.
The parent is the node which is higher in the hierarchy and the child the one that is lower. Siblings are items which have one and the same parent. Items can be expanded and collapsed.
Note: Read the API tab to find all available options and advanced customization
Basic example
- One
- Two
-
Three
- Second-one
- Second-two
-
Second-three
-
Third-one
- Fourth-one
- Fourth-two
- Fourth-three
- Third-two
-
Third-three
- Fourth-one
- Fourth-two
- Fourth-three
-
Third-one
Open on item click
Use a [openOnClick]
to define opening lists of treeview by click only on
the arrow or on the whole list item.
- One
- Two
-
Three
- Second-one
- Second-two
-
Second-three
-
Third-one
- Fourth-one
- Fourth-two
- Fourth-three
- Third-two
-
Third-three
- Fourth-one
- Fourth-two
- Fourth-three
-
Third-one
Accordion
Use a [accordion]
input to enable or disable opening only one list at
the same level.
- One
- Two
-
Three
- Second-one
- Second-two
-
Second-three
-
Third-one
- Fourth-one
- Fourth-two
- Fourth-three
- Third-two
-
Third-three
- Fourth-one
- Fourth-two
- Fourth-three
-
Third-one
Selectable
Use a [selectable]
input to set up checkboxes in every list item.
- One
- Two
-
Three
- Second-one
- Second-two
-
Second-three
-
Third-one
- Fourth-one
- Fourth-two
- Fourth-three
- Third-two
-
Third-three
- Fourth-one
- Fourth-two
- Fourth-three
-
Third-one
Expand
Expand your treeview to the particular list using the
expand(ID)
method.
- One
- Two
-
Three
- Second-one
- Second-two
-
Second-three
-
Third-one
- Fourth-one
- Fourth-two
- Fourth-three
- Third-two
-
Third-three
- Fourth-one
- Fourth-two
- Fourth-three
-
Third-one
Collapse
Collapse your treeview using the collapse()
method.
- One
- Two
-
Three
- Second-one
- Second-two
-
Second-three
-
Third-one
- Fourth-one
- Fourth-two
- Fourth-three
- Third-two
-
Third-three
- Fourth-one
- Fourth-two
- Fourth-three
-
Third-one
Custom icons
Add icons to the list elements by pasting an icon code in the
icon
property.
Use a [rotationAngle]
input to define a rotation angle of nested
lists icons.
- One
- Two
-
Three
- Second-one
- Second-two
-
Second-three
- Third-one
- Third-two
- Third-three
Color
Set the color of an active item using the
[color]
input.
Current color: primary
- One
- Two
-
Three
- Second-one
- Second-two
-
Second-three
-
Third-one
- Fourth-one
- Fourth-two
- Fourth-three
- Third-two
-
Third-three
- Fourth-one
- Fourth-two
- Fourth-three
-
Third-one
Line
Use a [line]
input to set up an additional line in every nested list.
- One
- Two
-
Three
- Second-one
- Second-two
-
Second-three
-
Third-one
- Fourth-one
- Fourth-two
- Fourth-three
- Third-two
-
Third-three
- Fourth-one
- Fourth-two
- Fourth-three
-
Third-one
Disabled
To generate a disabled list item, use disabled
property. You can expand disabled items, but you can't select them.
- One
- Two
-
Three
- Second-one
- Second-two
-
Second-three
-
Third-one
- Fourth-one
- Fourth-two
- Fourth-three
- Third-two
-
Third-three
- Fourth-one
- Fourth-two
- Fourth-three
-
Third-one
Filter
Use the .filter(string)
method to expand list items that meet your requirements.
- One
- Two
-
Three
- Second-one
- Second-two
-
Second-three
-
Third-one
- Fourth-one
- Fourth-two
- Fourth-three
- Third-two
-
Third-three
- Fourth-one
- Fourth-two
- Fourth-three
-
Third-one
Tree view - API
Installation
To install and configure the plugin follow our Plugins Installation Guide. Please remember to update all the plugin names and import paths. You can find all the necessary information in the Import section.
Import
Inputs
Name | Type | Default | Description |
---|---|---|---|
color
|
MdbTreeviewColor | 'primary' |
Defines a text and background color for an active or hovered item |
openOnClick
|
Boolean | true |
Enables opening list by clicking only on the icon |
selectable
|
Boolean | false |
Setup checkboxes for the every list item |
accordion
|
Boolean | false |
Allows only one list on the same level to be opened |
rotationAngle
|
String | 90 |
Defines a rotation angle of the icons in nested lists |
line
|
Boolean | false |
Adds a line to every nested list |
Outputs
Name | Type | Description |
---|---|---|
selected
|
EventEmitter<any> | This output fires immediately when one of the treeview checkboxes are changed. |
activeItemChange
|
EventEmitter<ElementRef> | This event fires immediately when one of the treeview list items are selected by click. |
Methods
Name | Description | Example |
---|---|---|
collapse
|
Collapses every list in treeview | treeview.collapse() |
expand(id:string)
|
Expands a treeview to the list with a particular ID | treeview.expand('example-id') |
filter(value:string)
|
Expands list items that meet your requirements | treeview.filter('Name') |