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>
<IcTreeViewheading="Menu"><IcTreeItemlabel="Coffee"/><IcTreeItemlabel="Tea"/><IcTreeItemlabel="Hot chocolate"/></IcTreeView>
Tree view details
Props
All components also accept native properties supported by the DOM, such asclassName
and
style
.
|
|
|
---|---|---|
|
The appearance of the tree view, e.g. dark, or light. |
|
|
The heading of the tree view. |
|
|
The size of the tree view. |
|
The appearance of the tree view, e.g. dark, or light. |
The heading of the tree view. |
The size of the tree view. |
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). |
|
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). |
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>
<IcTreeViewheading="Menu"><IcTreeItemlabel="Coffee"><IcTreeItemlabel="Americano"/><IcTreeItemlabel="Latte"/><IcTreeItemlabel="Espresso"/></IcTreeItem><IcTreeItemlabel="Tea"><IcTreeItemlabel="Earl Grey"/><IcTreeItemlabel="Chai"/></IcTreeItem><IcTreeItemlabel="Hot chocolate"/></IcTreeView>
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>
<IcTreeViewheading="Menu"><SlottedSVGslot="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"/></SlottedSVG><IcTreeItemlabel="Coffee"><SlottedSVGslot="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"/></SlottedSVG><IcTreeItemlabel="Americano"/><IcTreeItemlabel="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></IcTreeItem><IcTreeItemlabel="Espresso"/></IcTreeItem><IcTreeItemlabel="Tea"><IcTreeItemlabel="Earl Grey"/><IcTreeItemlabel="Chai"/></IcTreeItem><IcTreeItemlabel="Hot chocolate"/></IcTreeView>
Small
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>
<IcTreeViewheading="Menu"size="small"><SlottedSVGslot="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"/></SlottedSVG><IcTreeItemlabel="Coffee"><SlottedSVGslot="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"/></SlottedSVG><IcTreeItemlabel="Americano"/><IcTreeItemlabel="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></IcTreeItem><IcTreeItemlabel="Espresso"/></IcTreeItem><IcTreeItemlabel="Tea"><IcTreeItemlabel="Earl Grey"/><IcTreeItemlabel="Chai"/></IcTreeItem><IcTreeItemlabel="Hot chocolate"/></IcTreeView>
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>
<IcTreeViewheading="Menu"size="large"><SlottedSVGslot="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"/></SlottedSVG><IcTreeItemlabel="Coffee"><SlottedSVGslot="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"/></SlottedSVG><IcTreeItemlabel="Americano"/><IcTreeItemlabel="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></IcTreeItem><IcTreeItemlabel="Espresso"/></IcTreeItem><IcTreeItemlabel="Tea"><IcTreeItemlabel="Earl Grey"/><IcTreeItemlabel="Chai"/></IcTreeItem><IcTreeItemlabel="Hot chocolate"/></IcTreeView>
Light
Interactive example
<ic-tree-viewheading="Menu"appearance="light"><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>
<IcTreeViewheading="Menu"appearance="light"><SlottedSVGslot="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"/></SlottedSVG><IcTreeItemlabel="Coffee"><SlottedSVGslot="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"/></SlottedSVG><IcTreeItemlabel="Americano"/><IcTreeItemlabel="Latte"><SlottedSVGslot="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"/></SlottedSVG></IcTreeItem><IcTreeItemlabel="Espresso"/></IcTreeItem><IcTreeItemlabel="Tea"><IcTreeItemlabel="Earl Grey"/><IcTreeItemlabel="Chai"/></IcTreeItem><IcTreeItemlabel="Hot chocolate"/></IcTreeView>
Disabled tree items
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>
<IcTreeViewheading="Menu"><SlottedSVGslot="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"/></SlottedSVG><IcTreeItemlabel="Coffee"><SlottedSVGslot="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"/></SlottedSVG><IcTreeItemlabel="Americano"/><IcTreeItemlabel="Latte"disabled><SlottedSVGslot="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"/></SlottedSVG></IcTreeItem><IcTreeItemlabel="Espresso"/></IcTreeItem><IcTreeItemlabel="Tea"><IcTreeItemlabel="Earl Grey"/><IcTreeItemlabel="Chai"disabled/></IcTreeItem><IcTreeItemlabel="Hot chocolate"disabled/></IcTreeView>
Slotted content
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>
<IcTreeView><IcTypographyvariant="subtitle-large"slot="heading">Menu</IcTypography><IcTreeItem><IcTypographyslot="label">Coffee</IcTypography></IcTreeItem><IcTreeItemlabel="Tea"/><IcTreeItemlabel="Hot chocolate"/></IcTreeView>
Truncated
Interactive example
<ic-tree-viewheading="Menu with nested options"><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"></ic-tree-item></ic-tree-view>
<IcTreeViewheading="Menu with nested options"><SlottedSVGslot="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"/></SlottedSVG><IcTreeItemlabel="Coffee"><SlottedSVGslot="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"/></SlottedSVG><IcTreeItemlabel="Americano"/><IcTreeItemlabel="Latte with extra milk and sugar"/><IcTreeItemlabel="Espresso"/></IcTreeItem><IcTreeItemlabel="Tea"><IcTreeItemlabel="Earl Grey"/><IcTreeItemlabel="Chai"/></IcTreeItem><IcTreeItemlabel="Hot chocolate with marshmallows"/></IcTreeView>
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>
<IcTreeViewheading="Menu"><IcTreeItemlabel="Coffee"href="#"/><IcTreeItemlabel="Tea"selectedhref="#"/><IcTreeItemlabel="Hot chocolate"disabledhref="#"/></IcTreeView>