Import
import { Tree } from '@strongtie/design-system/tree' ;
Usage
< Tree >
< TreeItem value = "app" label = "app" >
< TreeItem value = "page.tsx" label = "page.tsx" />
< TreeItem value = "layout.tsx" label = "layout.tsx" />
</ TreeItem >
< TreeItem value = "components" label = "components" >
< TreeItem value = "header.tsx" label = "header.tsx" />
< TreeItem value = "footer.tsx" label = "footer.tsx" />
</ TreeItem >
</ Tree >
<Tree> PropsWhether tree items can be selected.
Whether multiple items can be selected at once.
Whether tree items can be collapsed and expanded.
Array of item values that should be expanded by default.
Default selected item value(s).
onSelect
(value: string | string[]) => void
Callback fired when selection changes.
onExpand
(expandedItems: string[]) => void
Callback fired when expanded state changes.
<TreeItem> PropsUnique identifier for the tree item.
Display text for the tree item.
Optional icon to display before the label.
Whether the tree item is disabled.
Usage Examples Basic Tree
With Custom Icons
Controlled Selection
Without Icons
const treeData = [
{
id: "1" ,
name: "src" ,
type: "folder" ,
children: [
{ id: "2" , name: "components" , type: "folder" },
{ id: "3" , name: "pages" , type: "folder" },
{ id: "4" , name: "index.ts" , type: "file" }
]
},
{
id: "5" ,
name: "package.json" ,
type: "file"
}
];
< Tree data = { treeData } onSelect = { ( item ) => console . log ( 'Selected:' , item ) } />
Styling Classes The following CSS classes are applied by the Tree component:
tree – Root tree container with basic styling and layout
tree-node-container – Container for each tree node with positioning
tree-line-container – Container for visual connection lines between nodes
tree-line – Visual lines connecting parent and child nodes
tree-button – Interactive button element for each tree node
tree-chevron – Expand/collapse indicator icon
tree-chevron-open – Applied when node is expanded
tree-spacer – Spacing element for nodes without children
tree-content – Content container for each node
tree-content-selected – Applied to selected tree nodes
tree-icon – Base class for node icons
tree-folder-icon – Specific styling for folder icons
tree-file-icon – Specific styling for file icons
tree-text – Text content within tree nodes
tree-text-no-icons – Text styling when icons are disabled
tree-collapsible-content – Container for child nodes
For more examples, visit the Storybook . < StudsTree >
< StudsTreeItem Text = "app" >
< StudsTreeItem Text = "page.tsx" />
< StudsTreeItem Text = "layout.tsx" />
</ StudsTreeItem >
< StudsTreeItem Text = "components" >
< StudsTreeItem Text = "header.tsx" />
< StudsTreeItem Text = "footer.tsx" />
</ StudsTreeItem >
</ StudsTree >
StudsTree ParametersGets or sets whether the tree displays checkboxes for each item.
Gets or sets whether checking a parent item also checks all its children.
Gets or sets whether checking children affects the parent’s checked state.
Gets or sets whether only one branch can be expanded at a time.
Gets or sets the selected item’s value.
Gets or sets the aria-label for the selected item.
Gets or sets the CSS class for the item content.
Gets or sets the CSS class for the item icon.
Gets or sets the CSS class for the item label.
Callback invoked when the selected value changes.
Gets or sets the collection of checked item values.
Specifies the collection of data items which StudsTree will create its items from.
ItemRender
Action<TreeItemRenderEventArgs>
A callback that will be invoked when item is rendered.
Gets or sets the child items content.
CheckedValuesChanged
EventCallback<IEnumerable<object>>
Callback invoked when the checked values collection changes.
Change
EventCallback<TreeEventArgs>
Callback invoked when an item is selected.
Expand
EventCallback<TreeExpandEventArgs>
Callback invoked when an item is expanded.
Collapse
EventCallback<TreeEventArgs>
Callback invoked when an item is collapsed.
Callback invoked when right-clicking an item.
Attributes
Dictionary<string, object>
Specifies additional custom attributes that will be rendered by the component.
MouseEnter
EventCallback<ElementReference>
Gets or sets the callback that is invoked when the mouse enters an item.
MouseLeave
EventCallback<ElementReference>
Gets or sets the callback that is invoked when the mouse leaves an item.
A callback that will be invoked when the user right-clicks the component. Commonly used to display a context menu.
Culture
CultureInfo
default: "CultureInfo.CurrentCulture"
Gets or sets the culture used to display localizable data (numbers, dates). Set by default to “CultureInfo.CurrentCulture”.
Gets or sets the inline CSS style.
Gets or sets a value indicating whether this “T:Studs.StudsComponent” is visible. Invisible components are not rendered.
StudsTreeItem ParametersGets or sets the display text of the tree item.
Gets or sets the value associated with this item.
Gets or sets whether this item can be checked.
Gets or sets whether this item has child items.
Gets or sets whether this item is expanded.
Gets or sets whether this item is selected.
Template
RenderFragment<StudsTreeItem>
Gets or sets custom template for rendering the item content.
Gets or sets the child items content.
The StudsTree which this item is part of.
The parent item of this tree item.
Gets or sets the CSS class for the item content.
Gets or sets the CSS class for the item icon.
Gets or sets the CSS class for the item label.
StudsTreeLevel ParametersFor data-bound scenarios: Specifies the property name to use for item text.
Specifies the name of the property which provides values for the Checkable property of the child items.
Specifies the property name that contains child items.
HasChildren
Func<object, bool>
default: "value => true"
Function that determines if an item has children.
Expanded
Func<object, bool>
default: "value => false"
Function that determines if an item should be expanded.
Selected
Func<object, bool>
default: "value => false"
Function that determines if an item should be selected.
Function that determines the display text for an item.
Determines the if the checkbox of the child item can be checked.
Template
RenderFragment<StudsTreeItem>
Gets or sets the template.
The StudsTree which this item is part of.
Attributes
Dictionary<string, object>
Specifies additional custom attributes that will be rendered by the component.
MouseEnter
EventCallback<ElementReference>
Gets or sets the callback that is invoked when the mouse enters an item.
MouseLeave
EventCallback<ElementReference>
Gets or sets the callback that is invoked when the mouse leaves an item.
A callback that will be invoked when the user right-clicks the component. Commonly used to display a context menu.
Culture
CultureInfo
default: "CultureInfo.CurrentCulture"
Gets or sets the culture used to display localizable data (numbers, dates). Set by default to “CultureInfo.CurrentCulture”.
Gets or sets the inline CSS style.
Gets or sets a value indicating whether this “T:Studs.StudsComponent” is visible. Invisible components are not rendered.
Usage Examples Basic Tree
With Checkboxes
Data-Bound Tree
With Custom Templates
With Events
< StudsTree >
< StudsTreeItem Text = "Documents" >
< StudsTreeItem Text = "report.pdf" />
< StudsTreeItem Text = "presentation.pptx" />
</ StudsTreeItem >
< StudsTreeItem Text = "Images" >
< StudsTreeItem Text = "photo1.jpg" />
< StudsTreeItem Text = "photo2.png" />
</ StudsTreeItem >
</ StudsTree >
Styling Classes The following CSS classes are applied by the Tree components:
tree – Root tree container with basic layout and styling
tree-container – List container for tree items with proper ARIA structure
tree-item – Individual tree item wrapper with hierarchy indicators
tree-item-content – Content area for each tree item
tree-item-icon – Icon display area for tree items
tree-item-label – Text label area for tree items
tree-item-expand – Expand/collapse button for parent nodes
tree-item-selected – Applied to selected tree items
tree-item-expanded – Applied to expanded parent items
tree-checkbox – Checkbox styling when AllowCheckBoxes is enabled
tree-level-{n} – Applied based on nesting depth for visual hierarchy
Custom classes can be applied via ItemContentCssClass, ItemIconCssClass, and ItemLabelCssClass parameters
For more examples, visit the Storybook .