React component for HTML structures based on a string, react component or DOM node
npm install @pahans/react-htmltree
> TreeView for HTML/XML structures
The motivation for this component was the lack of a standalone TreeView for HTML documents,
which can be easily integrated. Existing solutions are often tightly coupled into specific projects
or don't provide necessary customizations options. While its original is based on the TreeView
implementation of react-devtools,
additional improvements regarding performance and usability were done.
Checkout the example in your browser.
Chrome DevTools | Firefox DevTools - Light | Firefox DevTools - Dark
:--------------:|:-------------------------:|:----------------------:
!Chrome DevTools Theme|!Firefox DevTools Theme - Light|!Firefox DevTools Theme - Dark
``js
import HTMLTree from 'react-htmltree'
`
source: Text | React Component | HTMLElement
`js
// others events include: 'hover', 'expand' and 'unfocus'
function handleSelect (element, component) {
console.log(element)
}
`
`js
// create wrapper around the matched components
function customRender (decorate, node) {
return decorate(function (Component) {
if (node.name === 'script') {
return (
Further examples can be found here.
Development
To build your own version run npm run dev for development (incl. watch) or npm run build` for production (minified).