
Security News
Feross on the 10 Minutes or Less Podcast: Nobody Reads the Code
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.
@react-md/tree
Advanced tools
Create accessible tree widgets following the tree view specifications using the material design styles and fairly customizable renderers and styles and reasonable defaults.
npm install --save @react-md/tree
It is also recommended to install these other packages as they work hand-in-hand with this package:
npm install --save @react-md/theme \
@react-md/typography \
@react-md/icon \
@react-md/material-icons \
@react-md/list
You should check out the full documentation for live examples and more customization information, but an example usage is shown below.
The main export from this package is the Tree component which allows you to
render a tree from TreeData which is really a lookup of
Record<TreeItemId, TreeItem>. The Tree component is fully controlled and
requires you to provide the selection and logic expansion with a few props. You
can use the useTreeItemExpansion and useTreeItemSelection hooks to get
pretty reasonable support out of the box including multi-select behavior.
If you are a Typescript user, this package also exports a decent amount of types
to help out such as the TreeData, BaseTreeItem, and TreeItemSorter.
Here's a quick example:
import React, { ReactElement, ReactNode } from "react";
import { render } from "react-dom";
import {
Tree,
TreeData,
BaseTreeItem,
useTreeItemExpansion,
useTreeItemSelection,
} from "@react-md/tree";
interface MyTreeItem extends BaseTreeItem {
name: string;
}
const data: TreeData<MyTreeItem> = {
"item-1-id": {
name: "Root Node",
itemId: " item-1-id",
parentId: null,
},
"item-2-id": {
name: "Child 1",
itemId: "item-2-id",
parentId: "item-1-id",
},
"item-3-id": {
name: "Child 2",
itemId: "item-3-id",
parentId: "item-1-id",
},
};
export default function Example(): ReactElement {
const selection = useTreeItemSelection([], false);
const expansion = useTreeItemExpansion([]);
return (
<Tree
id="example-tree"
aria-label="Tree"
data={data}
{...selection}
{...expansion}
/>
);
}
FAQs
A package for creating an accessible tree component following the tree role.
The npm package @react-md/tree receives a total of 1,013 weekly downloads. As such, @react-md/tree popularity was classified as popular.
We found that @react-md/tree demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.

Research
/Security News
Campaign of 108 extensions harvests identities, steals sessions, and adds backdoors to browsers, all tied to the same C2 infrastructure.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.