sterling-svelte  2.0.23
A modern, accessible, lightweight UI component library for Svelte.

TreeItem

An item within a tree hierarchy that can contain other items.

Code
<script lang="ts">
  import { TreeItem } from '@geoffcox/sterling-svelte';
</script>

<TreeItem label="sterling-svelte" value="item" />

Members

Property NameTypeBindableDefaultComment
disabledboolean | null | undefinednofalseWhen true, the item and its children are disabled.
iconSnippet | undefinednoundefinedThe leaf or expand/collapse icon. When undefined renders TreeChevron.
labelstring | Snippet | undefinednoundefinedThe label for the item. When undefined renders the value.
valuestringnoThe value uniquely identifying this item within the tree.

Method NameParametersReturn TypeComment
collapseCollapses the current item.
expandExpands the current item.
selectSelects the current item.
selectParentSelects the parent of the current item.
selectPreviousSelects the previous item relative to the current item.
selectNextSelects the next item relative to the current item.
toggleExpandedToggles the expanded state of the current item.

Considerations

  • A tree item is identified by having data-value and role="treeitem" properties.
  • Includes HTMLDivElement props, events, and methods.

Anatomy

<div class="sterling-tree-item">
  <div class="item">
    {@render icon()}
    {@render label()}
  </div>
  <div class="children">
    {@render children()}
  </div>
</div>