
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@hig/tree-view
Advanced tools
The tree view component provides a way to view and manipulate a list of data, often with complex nested structures.
Read more about when and how to use the TreeView component on the internal wiki.
yarn add @hig/tree-view @hig/theme-context @hig/theme-data
import TreeView, { TreeItem } from "@hig/tree-view";
<TreeView>
<TreeItem label="Tree Item 1" id="tree-item-1">
<TreeItem label="Tree Item 2" id="tree-item-2">
<TreeItem label="Tree Item 3" id="tree-item-3">
<TreeItem label="Tree Item 4" id="tree-item-4" />
<TreeItem label="Tree Item 5" id="tree-item-5" />
<TreeItem label="Tree Item 6" id="tree-item-6" />
</TreeItem>
</TreeItem>
</TreeItem>
</TreeView>
const FileTreeCollection = {
id: 1,
index: 0,
parentId: null,
meta: {
label: "Tree Item 1",
collapsed: false,
active: false,
disabled: false,
icon: <Calendar24 />,
},
children: [
{
id: 2,
index: 1,
parentId: 1,
meta: {
label: "Tree Item 2",
collapsed: false,
active: false,
disabled: false,
icon: null,
},
},
{
id: 3,
index: 2,
parentId: 1,
meta: {
label: "Tree Item 3",
collapsed: false,
active: false,
icon: <Folder24 />,
},
children: [
{
id: 4,
index: 3,
parentId: 3,
meta: {
label: "Tree Item 4",
collapsed: false,
active: false,
icon: null,
},
},
],
},
],
};
Use the className
prop to pass in a css class name to the outermost container of the component. The class name will also pass down to most of the other styled elements within the component.
TreeView also has a stylesheet
prop that accepts a function wherein you can modify TreeView's styles. The original styles, props, current theme data and theme meta will be passed to your custom stylesheet function, and it should return an object with the same structure as the original styles. For instance:
function customStylesheet(styles, props, themeData) {
return {
...styles,
higTreeViewWrapper: {
...styles.higTreeViewWrapper,
backgroundColor: "yellow"
},
higTreeView: {
...styles.higTreeView,
backgroundColor: "black"
},
higTreeItem: {
...styles.higTreeItem,
backgroundColor: themeData["basics.colors.green100"]
},
higTreeItemContentWrapper: {
...styles.higTreeItemContentWrapper,
padding: 0
},
higTreeItemSubTreeViewWrapper: {
...styles.higTreeItemSubTreeViewWrapper,
margin: 0
},
higTreeItemSubTreeView: {
...styles.higTreeItemSubTreeView,
fontSize: "14px"
},
higTreeItemSubTreeViewLabelWrapper: {
...styles.shortcutWrapper,
overflow: "hidden"
},
higTreeItemSubTreeViewLabelContentWrapper: {
...styles.higTreeItemSubTreeViewLabelContentWrapper,
width: "100%"
},
higTreeItemSubTreeItem: {
...styles.higTreeItemSubTreeItem,
textAlign: "center"
},
higTreeItemIndicatorWrapper: {
...styles.higTreeItemIndicatorWrapper,
backgroundColor: "transparent"
},
higTreeItemIconWrapper: {
...styles.higTreeItemIconWrapper,
height: "36px"
},
higTreeItemLabelWrapper: {
...styles.higTreeItemLabelWrapper,
fontWeight: 900
}
};
}
<TreeView stylesheet={customStylesheet}>
<TreeItem label="Tree Item 1" id="tree-item-1" stylesheet={customStylesheet}>
<TreeItem label="Tree Item 2" id="tree-item-2">
<TreeItem label="Tree Item 3" id="tree-item-3">
<TreeItem label="Tree Item 4" id="tree-item-4" />
<TreeItem label="Tree Item 5" id="tree-item-5" />
<TreeItem label="Tree Item 6" id="tree-item-6" />
</TreeItem>
</TreeItem>
</TreeItem>
</TreeView>;
FAQs
HIG Tree View
We found that @hig/tree-view demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.