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

Tree

A hierarchy of items that can be expanded/collapsed and where a single item can be selected.

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

  let expandedValues: string[] = [];
  let selectedValue: string | undefined = undefined;
</script>

<Tree bind:expandedValues bind:selectedValue>
  <!-- <TreeItem> ... -->
</List>

Members

Property NameTypeDefaultComment
disabledboolean | null | undefinedfalseWhen true, the tree and its descendants are disabled.
selectedValuestring | undefinedundefinedThe value of the currently selected item.
expandedValuesstring[] | undefined[ ]The values of items that are expanded.
onExpandCollapse(expandedValues: string) => nullundefinedCalled when any item in the hierarchy is expanded or collapsed.
onSelect(selectedValue: string) => nullundefinedCalled when any item in the hierarchy is selected.

Considerations

  • Includes HTMLDivElement props, events, and methods.

Anatomy

tree (<div>)
  children (Snippet)