Getting Started
Foundations
Components
Search for a command to run...
This component serves as the container for tree items and manages the overall tree display. It accepts tree data and configuration options, then renders TreeNode components for each top-level item.
import { Tree } from "@strongtie/design-system/tree"<Tree>| Prop | Type | Default | Description |
|---|---|---|---|
data * | TreeItem[] | - | Array of tree items to display in the hierarchical structure. Each item can have children to create nested levels. Items with children will be expandable/collapsible. |
fileIcon | ReactNode | - | Custom icon to use for all file-type items. Overrides the default file icon for items with type='file' or items without children. Individual items can still override this with their own icon property. |
folderIcon | ReactNode | - | Custom icon to use for all folder-type items. Overrides the default folder icon for items with type='folder' or items that have children. Individual items can still override this with their own icon property. |
onSelect | ((item: TreeItem) => void) | - | Callback fired when a tree item is clicked. Receives the clicked tree item as an argument. Use this to handle navigation, selection state, or trigger actions based on the selected item. |
selectedId | string | - | The ID of the currently selected tree item. When provided, the tree item with this ID will be visually highlighted. Use this for controlled selection state. |
showIcons | boolean | true | Whether to display icons next to tree items. When true, shows type-based icons (folder/file) or custom icons provided in the tree item data. |
Components can be styled using the className prop. The design system uses Tailwind CSS for styling.
Other CSS classes used by this component:
?isSelectedtreetree-buttontree-chevrontree-collapsible-contenttree-file-icontree-folder-icontree-icontree-linetree-line-containertree-nodetree-node-containertree-spacertree-textEnsure proper accessibility attributes are added when implementing this component.