sterling-svelte  2.0.0
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 NameTypeDefaultComment
disabledboolean | null | undefinedfalseWhen true, the item and its children are disabled.
iconSnippet | undefinedundefinedThe leaf or expand/collapse icon. When undefined renders TreeChevron.
labelstring | Snippet | undefinedundefinedThe label for the item. When undefined renders the value.
valuestringThe 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

tree-item (div)
  item (div)
    icon (Snippet)
    label (string | Snippet)
  children (Snippet)