- Plugins
- Tree View
Plugins
Tailwind CSS Tree View Plugin API
Headless, unstyled Tree View plugin built with JavaScript and TypeScript, including installation, usage, options, methods, events, and selectors.
Installation
To get started, install Tree View plugin via npm, or skip this step if you are already using Preline UI as a package.
Terminal
npm i @preline/tree-view @preline/accordion
Example
Here is a basic example of a Tree View.
assets
css
main
main.css
docs.css
README.txt
tailwind
.gitignore
img
js
scripts
templates
Methods
The HSTreeView object is contained within the global window object
Update element.
const treeView = HSTreeView.getInstance('#tree-view', true);
const updateBtn = document.querySelector('#update-btn');
updateBtn.addEventListener('click', () => {
treeView.element.update();
});
Get selected items.
const treeView = HSTreeView.getInstance('#tree-view', true);
const getItemsBtn = document.querySelector('#get-items-btn');
getItemsBtn.addEventListener('click', () => {
console.log(treeView.element.getSelectedItems());
});
Events
When select changes event example.
const el = HSTreeView.getInstance('#tree-view', true);
el.element.on('click', (data) => {...});
Demo examples
Looking for prebuilt UI components based on the Tailwind CSS? Preline UI packs hundreds of component examples for all your website needs.
Check out Preline UI Components