Tree view
Tree view
Component demo
Interactive example
<ic-tree-viewheading="Menu"><ic-tree-itemlabel="Coffee"></ic-tree-item><ic-tree-itemlabel="Tea"></ic-tree-item><ic-tree-itemlabel="Hot chocolate"></ic-tree-item></ic-tree-view>
Tree view details
Props
All components also accept native properties supported by the DOM, such asclassName
and
style
.
|
|
|
---|---|---|
|
The heading of the tree view. |
|
|
The size of the tree view. |
|
|
Sets the theme color to the dark or light theme color. "inherit" will set the color based on the system settings or ic-theme component. |
|
|
The content within the tree view tree items. This will take precedence over slotted content. |
|
|
If |
|
|
If |
|
The heading of the tree view. |
The size of the tree view. |
Sets the theme color to the dark or light theme color. "inherit" will set the color based on the system settings or ic-theme component. |
The content within the tree view tree items. This will take precedence over slotted content. |
If |
If |
Slots
A slot allows for any type of element or markup to be passed into and rendered within a web component. This creates more flexibility than using a prop which must take a specific type of data.
Content can be slotted into a component by adding it as a top-level child of the component.
Slots can have a name to identify them. These specify which slot the content will be inserted into, and therefore where it will be rendered and how it will be used within the component. The name of the slot to be used can be specified by passing it via a
slot
attribute on the slotted content.
|
|
---|---|
|
|
|
|
|
|
CSS Custom Properties
|
|
---|---|
|
|
|
Tree item details
Props
All components also accept native properties supported by the DOM, such asclassName
and
style
.
|
|
|
---|---|---|
|
If |
|
|
If |
|
|
The URL that the tree item link points to. If set, the tree item will render as an "a" tag, otherwise it will render as a div. |
|
|
The human language of the linked URL. |
|
|
The label of the tree item. |
|
|
How much of the referrer to send when following the link. |
|
|
The relationship of the linked URL as space-separated link types. |
|
|
If |
|
|
The place to display the linked URL, as the name for a browsing context (a tab, window, or iframe). |
|
|
Sets the theme color to the dark or light theme color. "inherit" will set the color based on the system settings or ic-theme component. |
|
|
Sets the tree item id. Must be unique. |
|
|
If |
|
If |
If |
The URL that the tree item link points to. If set, the tree item will render as an "a" tag, otherwise it will render as a div. |
The human language of the linked URL. |
The label of the tree item. |
How much of the referrer to send when following the link. |
The relationship of the linked URL as space-separated link types. |
If |
The place to display the linked URL, as the name for a browsing context (a tab, window, or iframe). |
Sets the theme color to the dark or light theme color. "inherit" will set the color based on the system settings or ic-theme component. |
Sets the tree item id. Must be unique. |
If |
Slots
A slot allows for any type of element or markup to be passed into and rendered within a web component. This creates more flexibility than using a prop which must take a specific type of data.
Content can be slotted into a component by adding it as a top-level child of the component.
Slots can have a name to identify them. These specify which slot the content will be inserted into, and therefore where it will be rendered and how it will be used within the component. The name of the slot to be used can be specified by passing it via a
slot
attribute on the slotted content.
|
|
---|---|
|
|
|
|
|
|
|
|
|
Events
All components also accept native events supported by the DOM, such as
onClick
and
onKeyDown
.
|
|
|
---|---|---|
|
|
|
|
|
|
|
|
Methods
|
|
|
---|---|---|
|
|
|
|
Variants
Nested levels
Interactive example
<ic-tree-viewheading="Menu"><ic-tree-itemlabel="Coffee"><ic-tree-itemlabel="Americano"></ic-tree-item><ic-tree-itemlabel="Latte"></ic-tree-item><ic-tree-itemlabel="Espresso"></ic-tree-item></ic-tree-item><ic-tree-itemlabel="Tea"><ic-tree-itemlabel="Earl Grey"></ic-tree-item><ic-tree-itemlabel="Chai"></ic-tree-item></ic-tree-item><ic-tree-itemlabel="Hot chocolate"></ic-tree-item></ic-tree-view>
Slotted icons
Interactive example
<ic-tree-viewheading="Menu"><svgslot="icon"xmlns="http://www.w3.org/2000/svg"viewBox="0 0 24 24"><pathd="M10,4H4C2.89,4 2,4.89 2,6V18A2,2 0 0,0 4,20H20A2,2 0 0,0 22,18V8C22,6.89 21.1,6 20,6H12L10,4Z"/></svg><ic-tree-itemlabel="Coffee"><svgslot="icon"xmlns="http://www.w3.org/2000/svg"viewBox="0 0 24 24"><pathd="M13,9V3.5L18.5,9M6,2C4.89,2 4,2.89 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2H6Z"/></svg><ic-tree-itemlabel="Americano"></ic-tree-item><ic-tree-itemlabel="Latte"><svgslot="icon"xmlns="http://www.w3.org/2000/svg"viewBox="0 0 24 24"><pathd="M13,9V3.5L18.5,9M6,2C4.89,2 4,2.89 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2H6Z"/></svg></ic-tree-item><ic-tree-itemlabel="Espresso"></ic-tree-item></ic-tree-item><ic-tree-itemlabel="Tea"><ic-tree-itemlabel="Earl Grey"></ic-tree-item><ic-tree-itemlabel="Chai"></ic-tree-item></ic-tree-item><ic-tree-itemlabel="Hot chocolate"></ic-tree-item></ic-tree-view>
Small
Small and large styling will be passed down from the tree view to tree items and nested tree items.
Interactive example
<ic-tree-viewheading="Menu"size="small"><svgslot="icon"xmlns="http://www.w3.org/2000/svg"viewBox="0 0 24 24"><pathd="M10,4H4C2.89,4 2,4.89 2,6V18A2,2 0 0,0 4,20H20A2,2 0 0,0 22,18V8C22,6.89 21.1,6 20,6H12L10,4Z"/></svg><ic-tree-itemlabel="Coffee"><svgslot="icon"xmlns="http://www.w3.org/2000/svg"viewBox="0 0 24 24"><pathd="M13,9V3.5L18.5,9M6,2C4.89,2 4,2.89 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2H6Z"/></svg><ic-tree-itemlabel="Americano"></ic-tree-item><ic-tree-itemlabel="Latte"><svgslot="icon"xmlns="http://www.w3.org/2000/svg"viewBox="0 0 24 24"><pathd="M13,9V3.5L18.5,9M6,2C4.89,2 4,2.89 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2H6Z"/></svg></ic-tree-item><ic-tree-itemlabel="Espresso"></ic-tree-item></ic-tree-item><ic-tree-itemlabel="Tea"><ic-tree-itemlabel="Earl Grey"></ic-tree-item><ic-tree-itemlabel="Chai"></ic-tree-item></ic-tree-item><ic-tree-itemlabel="Hot chocolate"></ic-tree-item></ic-tree-view>
Large
Interactive example
<ic-tree-viewheading="Menu"size="large"><svgslot="icon"xmlns="http://www.w3.org/2000/svg"viewBox="0 0 24 24"><pathd="M10,4H4C2.89,4 2,4.89 2,6V18A2,2 0 0,0 4,20H20A2,2 0 0,0 22,18V8C22,6.89 21.1,6 20,6H12L10,4Z"/></svg><ic-tree-itemlabel="Coffee"><svgslot="icon"xmlns="http://www.w3.org/2000/svg"viewBox="0 0 24 24"><pathd="M13,9V3.5L18.5,9M6,2C4.89,2 4,2.89 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2H6Z"/></svg><ic-tree-itemlabel="Americano"></ic-tree-item><ic-tree-itemlabel="Latte"><svgslot="icon"xmlns="http://www.w3.org/2000/svg"viewBox="0 0 24 24"><pathd="M13,9V3.5L18.5,9M6,2C4.89,2 4,2.89 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2H6Z"/></svg></ic-tree-item><ic-tree-itemlabel="Espresso"></ic-tree-item></ic-tree-item><ic-tree-itemlabel="Tea"><ic-tree-itemlabel="Earl Grey"></ic-tree-item><ic-tree-itemlabel="Chai"></ic-tree-item></ic-tree-item><ic-tree-itemlabel="Hot chocolate"></ic-tree-item></ic-tree-view>
Theme
Interactive example
<ic-tree-viewheading="Menu"theme="dark"><svgslot="icon"xmlns="http://www.w3.org/2000/svg"viewBox="0 0 24 24"><pathd="M10,4H4C2.89,4 2,4.89 2,6V18A2,2 0 0,0 4,20H20A2,2 0 0,0 22,18V8C22,6.89 21.1,6 20,6H12L10,4Z"/></svg><ic-tree-itemlabel="Coffee"><svgslot="icon"xmlns="http://www.w3.org/2000/svg"viewBox="0 0 24 24"><pathd="M13,9V3.5L18.5,9M6,2C4.89,2 4,2.89 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2H6Z"/></svg><ic-tree-itemlabel="Americano"></ic-tree-item><ic-tree-itemlabel="Latte"><svgslot="icon"xmlns="http://www.w3.org/2000/svg"viewBox="0 0 24 24"><pathd="M13,9V3.5L18.5,9M6,2C4.89,2 4,2.89 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2H6Z"/></svg></ic-tree-item><ic-tree-itemlabel="Espresso"></ic-tree-item></ic-tree-item><ic-tree-itemlabel="Tea"><ic-tree-itemlabel="Earl Grey"></ic-tree-item><ic-tree-itemlabel="Chai"></ic-tree-item></ic-tree-item><ic-tree-itemlabel="Hot chocolate"></ic-tree-item></ic-tree-view>
Disabled tree items
Individual tree-items can be disabled using thedisabled
prop.
Interactive example
<ic-tree-viewheading="Menu"><svgslot="icon"xmlns="http://www.w3.org/2000/svg"viewBox="0 0 24 24"><pathd="M10,4H4C2.89,4 2,4.89 2,6V18A2,2 0 0,0 4,20H20A2,2 0 0,0 22,18V8C22,6.89 21.1,6 20,6H12L10,4Z"/></svg><ic-tree-itemlabel="Coffee"><svgslot="icon"xmlns="http://www.w3.org/2000/svg"viewBox="0 0 24 24"><pathd="M13,9V3.5L18.5,9M6,2C4.89,2 4,2.89 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2H6Z"/></svg><ic-tree-itemlabel="Americano"></ic-tree-item><ic-tree-itemlabel="Latte"disabled="true"><svgslot="icon"xmlns="http://www.w3.org/2000/svg"viewBox="0 0 24 24"><pathd="M13,9V3.5L18.5,9M6,2C4.89,2 4,2.89 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2H6Z"/></svg></ic-tree-item><ic-tree-itemlabel="Espresso"></ic-tree-item></ic-tree-item><ic-tree-itemlabel="Tea"><ic-tree-itemlabel="Earl Grey"></ic-tree-item><ic-tree-itemlabel="Chai"disabled="true"></ic-tree-item></ic-tree-item><ic-tree-itemlabel="Hot chocolate"disabled="true"></ic-tree-item></ic-tree-view>
Slotted content
Custom content can be passed to both the tree view (using theheading
slot) and tree-items (using thelabel
slot).
Interactive example
<ic-tree-view><ic-typographyvariant="subtitle-large"slot="heading">Menu</ic-typography><ic-tree-item><ic-typographyslot="label">Coffee</ic-typography></ic-tree-item><ic-tree-itemlabel="Tea"></ic-tree-item><ic-tree-itemlabel="Hot chocolate"></ic-tree-item></ic-tree-view>
Truncated
When the heading exceeds the width of the container, the text will wrap unlesstruncateTreeItem
ortruncateHeading
are set totrue
.
Interactive example
<ic-tree-viewheading="Menu with nested options"truncate-heading="true"><svgslot="icon"xmlns="http://www.w3.org/2000/svg"viewBox="0 0 24 24"><pathd="M10,4H4C2.89,4 2,4.89 2,6V18A2,2 0 0,0 4,20H20A2,2 0 0,0 22,18V8C22,6.89 21.1,6 20,6H12L10,4Z"/></svg><ic-tree-itemlabel="Coffee"><svgslot="icon"xmlns="http://www.w3.org/2000/svg"viewBox="0 0 24 24"><pathd="M13,9V3.5L18.5,9M6,2C4.89,2 4,2.89 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2H6Z"/></svg><ic-tree-itemlabel="Americano"></ic-tree-item><ic-tree-itemlabel="Latte with extra milk and sugar"></ic-tree-item><ic-tree-itemlabel="Espresso"></ic-tree-item></ic-tree-item><ic-tree-itemlabel="Tea"><ic-tree-itemlabel="Earl Grey"></ic-tree-item><ic-tree-itemlabel="Chai"></ic-tree-item></ic-tree-item><ic-tree-itemlabel="Hot chocolate with marshmallows"truncate-tree-item="true"></ic-tree-item></ic-tree-view>
Link
When setting thehref
attribute, the tree-item will function as a link.
Interactive example
<ic-tree-viewheading="Menu"><ic-tree-itemlabel="Coffee"href="#"></ic-tree-item><ic-tree-itemlabel="Tea"selected="true"href="#"></ic-tree-item><ic-tree-itemlabel="Hot chocolate"disabled="true"href="#"></ic-tree-item></ic-tree-view>
With React Router
Interactive example
<divstyle={{ display:"flex", flexDirection:"row", gap:"16px"}}><divstyle={{ width:"250px"}}><IcTreeViewheading="Menu"><IcTreeItemselected={isSelected("/")}><NavLinkslot="router-item"to="/"> Home</NavLink></IcTreeItem><IcTreeItemselected={isSelected("/coffee")}><NavLinkslot="router-item"to="/coffee"> Coffee</NavLink></IcTreeItem><IcTreeItemselected={isSelected("/tea")}><NavLinkslot="router-item"to="/tea"> Tea</NavLink></IcTreeItem></IcTreeView></div><divstyle={{ marginTop:"16px"}}><Routes><Routepath="/"element={<IcTypography>Home Page</IcTypography>}/><Routepath="/coffee"element={<IcTypography>Coffee Page</IcTypography>}/><Routepath="/tea"element={<IcTypography>Tea Page</IcTypography>}/></Routes></div></div>