Basic
The simplest instance of the component, a good base on which a custom component can be built.
- src
- node_modules
- .npmignore
- package.json
- webpack.config.js
import React from "react";
import TreeView, { flattenTree } from "react-accessible-treeview";
import "./styles.css";
const folder = {
name: "",
children: [
{
name: "src",
children: [{ name: "index.js" }, { name: "styles.css" }],
},
{
name: "node_modules",
children: [
{
name: "react-accessible-treeview",
children: [{ name: "bundle.js" }],
},
{ name: "react", children: [{ name: "bundle.js" }] },
],
},
{
name: ".npmignore",
},
{
name: "package.json",
},
{
name: "webpack.config.js",
},
],
};
const data = flattenTree(folder);
const BasicTreeView = () => (
<TreeView
data={data}
className="basic"
aria-label="basic example tree"
nodeRenderer={({ element, getNodeProps, level, handleSelect }) => (
<div {...getNodeProps()} style={{ paddingLeft: 20 * (level - 1) }}>
{element.name}
</div>
)}
/>
);
export default BasicTreeView;
.basic.tree {
list-style: none;
margin: 0;
padding: 20px;
}
.basic .tree-node,
.basic .tree-node-group {
list-style: none;
margin: 0;
padding: 0;
}
.basic .tree-branch-wrapper,
.basic .tree-node__leaf {
outline: none;
}
.basic .tree-node--focused {
outline-color: rgb(77, 144, 254);
outline-style: auto;
outline-width: 2px;
display: block;
}
.basic .tree-node__branch {
display: block;
}
.basic .tree-node {
cursor: pointer;
}