Tree
A hierarchical list of items
- index.svelte
- lib
- tree
- Tree.svelte
- TreeItem.svelte
- icons
- JavaScript.svelte
- Svelte.svelte
- index.js
- routes
- contents
- +layout.svelte
- +page.svelte
Props
Features
- 🎹 Keyboard navigation
- 🍃 Multi-selection mode
- 🧠 Smart focus management
- 🌳 Optional expand on click
Usage
API Reference
Constructor Props
The props that are passed when calling
Methods
The methods returned from
-
isSelected
Checks if an item is currently selected @param id - ID of the item to check -
isExpanded
Checks if an item is currently expanded @param id - ID of the item to check -
expand
Expands a specific item @param id - ID of the item to expand -
collapse
Collapses a specific item @param id - ID of the item to collapse -
toggleExpand
Toggles the expanded state of an item @param id - ID of the item to toggle -
select
Selects a specific item @param id - ID of the item to select -
deselect
Deselects a specific item @param id - ID of the item to deselect -
clearSelection
Clears all current selections -
toggleSelect
Toggles the selected state of an item @param id - ID of the item to toggle -
selectAll
Selects all visible items. If all items are already selected, clears the selection. -
getItemId
Gets the DOM ID for a specific tree item @param id - ID of the item -
getItemEl
Gets the DOM element for a specific tree item @param id - ID of the item -
selectUntil
Selects all items between the last selected item and the specified item @param id - ID of the item to select until -
typeahead
Properties
The properties returned from
-
items
The items contained in the tree -
multiple
If -
expandOnClick
If -
typeaheadTimeout
-
selected
Currently selected item(s) For multiple selection, returns a Set of IDs For single selection, returns a single ID or undefined -
expanded
Set of currently expanded item IDs -
root
Gets ARIA attributes for the root tree element -
group
ARIA attributes for group elements -
children
Array of Child instances representing the top-level items