Skip to content

Tree View ​

Simple Tree View

Loading...

Rich Tree View

Loading...

Rich Tree View with Drag & Drop Reordering

Loading...

<flint-rich-tree-view> ​

A data-driven tree view that renders its structure from an items array.

  • Tag: <flint-rich-tree-view>
  • Class: FlintRichTreeView

Import ​

ts
import '@getufy/flint-ui'; // auto-registers all
// or
import { FlintRichTreeView } from '@getufy/flint-ui';

Usage ​

html
<flint-rich-tree-view></flint-rich-tree-view>

Properties ​

PropertyAttributeTypeDefaultDescription
itemsitemsRichTreeItem[][]Array of item data objects.
dataSourcedataSourceRichTreeViewDataSource—Optional lazy-load data source.
getItemIdgetItemId(item) =&gt; string—Extract unique ID (default: item.id).
getItemLabelgetItemLabel(item) =&gt; string—Extract label (default: item.label).
getItemChildrengetItemChildren(item) =&gt; RichTreeItem[] | undefined—Extract children (default: item.children).
isItemDisabledisItemDisabled(item) =&gt; boolean—Return true to disable an item.
disabledItemsFocusabledisabled-items-focusablebooleanfalseWhen true, disabled items can receive keyboard focus.
onItemClickonItemClick(itemId: string) =&gt; void | undefined—Callback invoked when a tree item is clicked or activated via keyboard.
expansionTriggerexpansion-trigger'content' | 'iconContainer''content'What interaction triggers expand/collapse.
expandedItemsexpandedItemsstring[] | undefined—Controlled mode. The set of item IDs that should be expanded.
defaultExpandedItemsdefaultExpandedItemsstring[][]Uncontrolled mode. Item IDs to expand on initial mount.
onExpandedItemsChangeonExpandedItemsChange(itemIds: string[]) =&gt; void | undefined—Callback fired when the user toggles an item's expansion.
itemsReorderingitems-reorderingbooleanfalseWhen true, enables drag-and-drop reordering of items.
isItemReorderableisItemReorderable(itemId: string) =&gt; boolean | undefined—Function that determines if a specific item can be reordered.
canMoveItemToNewPositioncanMoveItemToNewPosition(params: &#123; itemId: string; targetId: string; position: 'before' | 'after' | 'inside'; &#125;) =&gt; boolean | undefined—Function that determines if an item can be moved to a specific target position.
itemsReorderingHandleitems-reordering-handlebooleanfalseWhether to use a drag handle icon for reordering.
onItemPositionChangeonItemPositionChange(params: &#123; itemId: string; newParentId: string | null; newIndex: number; &#125;) =&gt; void | undefined—Fired when an item's position changes via reordering.
selectionModeselection-mode'none' | 'single' | 'multiple''none'Selection mode:
selectedItemsselectedItemsstring[] | undefined—Controlled mode. The set of selected item IDs.
defaultSelectedItemsdefaultSelectedItemsstring[][]Uncontrolled mode. Item IDs selected on initial mount.
onSelectedItemsChangeonSelectedItemsChange(itemIds: string[]) =&gt; void | undefined—Callback fired when the selection changes.
selectionPropagationselection-propagationbooleanfalseWhen true (and selectionMode='multiple'), selecting a parent item

Events ​

EventDetailDescription
flint-selection-change&#123; selectedItems &#125;When the selected set changes (detail: { selectedItems })
flint-tree-view-expanded-items-change&#123; expandedItems &#125;When the expanded set changes (detail: { expandedItems })
flint-tree-view-item-click&#123; itemId &#125;When a tree item is activated (detail: { itemId })
flint-tree-view-error&#123; message, id, error &#125;When a lazy-loading dataSource call fails (detail: { message, id, error })

CSS Custom Properties ​

PropertyDefault
--flint-font-family—
--flint-text-color—
--flint-primary-color—
--flint-border-radius-sm—
--flint-hover-color—
--flint-active-color—
--flint-primary-color-light—
--flint-border-color—
--flint-text-color-muted—

Methods ​

MethodDescription
getItem(id: string): RichTreeItem | nullReturns the data item with the given ID, or null if not found.
getItemDOMElement(id: string): FlintTreeItem | nullReturns the DOM element for the tree item with the given ID, or null.
getItemTree(): RichTreeItem[]Returns the current items tree. Returns the reordered tree if reordering is active.
getItemOrderedChildrenIds(itemId: string | null): string[]Returns the ordered child IDs for an item, or root items if null.
setIsItemDisabled(id: string, disabled: boolean): voidImperatively toggle the disabled state of an item by ID.

<flint-simple-tree-view> ​

A simple tree-view container that manages keyboard navigation, focus, and item selection/expansion for nested flint-tree-item elements.

  • Tag: <flint-simple-tree-view>
  • Class: FlintSimpleTreeView

Import ​

ts
import '@getufy/flint-ui'; // auto-registers all
// or
import { FlintSimpleTreeView } from '@getufy/flint-ui';

Usage ​

html
<flint-simple-tree-view></flint-simple-tree-view>

Properties ​

PropertyAttributeTypeDefaultDescription
disabledItemsFocusabledisabled-items-focusablebooleanfalseWhen true, disabled items can receive keyboard focus.
onItemClickonItemClick(itemId: string) =&gt; void | undefined—Callback invoked when a tree item is clicked or activated via keyboard.
expandedItemsexpandedItemsstring[] | undefined—Controlled mode. The set of item IDs that should be expanded.
defaultExpandedItemsdefaultExpandedItemsstring[][]Uncontrolled mode. Item IDs to expand on initial mount.
onExpandedItemsChangeonExpandedItemsChange(itemIds: string[]) =&gt; void | undefined—Callback fired when the user toggles an item's expansion.
expansionTriggerexpansion-trigger'content' | 'iconContainer''content'What interaction triggers expand/collapse.
selectionModeselection-mode'none' | 'single' | 'multiple''none'Selection mode:
selectedItemsselectedItemsstring[] | undefined—Controlled mode. The set of selected item IDs.
defaultSelectedItemsdefaultSelectedItemsstring[][]Uncontrolled mode. Item IDs selected on initial mount.
onSelectedItemsChangeonSelectedItemsChange(itemIds: string[]) =&gt; void | undefined—Callback fired when the selection changes.

Events ​

EventDetailDescription
flint-selection-change&#123; selectedItems &#125;When the selected set changes (detail: { selectedItems })
flint-tree-view-expanded-items-change&#123; expandedItems &#125;When the expanded set changes (detail: { expandedItems })
flint-tree-view-item-click&#123; itemId &#125;When a tree item is activated (detail: { itemId })

Slots ​

NameDescription
(default)Place flint-tree-item elements here.

CSS Parts ​

NameDescription
baseThe component's base wrapper element.

Methods ​

MethodDescription
getItemDOMElement(itemId: string): FlintTreeItem | nullReturns the DOM element for the tree item with the given itemId,

<flint-tree-item> ​

A single item inside a flint-simple-tree-view or flint-rich-tree-view.

  • Tag: <flint-tree-item>
  • Class: FlintTreeItem

Import ​

ts
import '@getufy/flint-ui'; // auto-registers all
// or
import { FlintTreeItem } from '@getufy/flint-ui';

Usage ​

html
<flint-tree-item></flint-tree-item>

Properties ​

PropertyAttributeTypeDefaultDescription
itemIditem-idstring''Unique identifier for this item within the tree
labellabelstring''Label text displayed for this item
disableddisabledbooleanfalseWhether this item is disabled (non-interactive)
expandedexpandedbooleanfalseWhether this item's children are visible
hasChildrenhas-childrenbooleanfalseWhen true, forces the expand button to render even if no flint-tree-item
selectedselectedbooleanfalseWhether this item is visually selected. Managed by the parent tree-view.
indeterminateindeterminatebooleanfalseWhether the checkbox is in an indeterminate state (some but not all children selected).
dropPositiondrop-position'before' | 'after' | 'inside' | nullnullVisual drop position indicator — reflected so CSS :host selectors match
showDragHandleshow-drag-handlebooleanfalseWhether to show a dedicated drag handle icon

Events ​

EventDetailDescription
flint-tree-item-click&#123; itemId, ctrlKey, shiftKey &#125;Fired when the item is clicked (detail: { itemId, ctrlKey, shiftKey })
flint-tree-item-toggle&#123; itemId, expanded &#125;Fired when expanded state changes (detail: { itemId, expanded })

Slots ​

NameDescription
leadLeading icon or content.
(default)Item label text.

CSS Parts ​

NameDescription
baseThe component's base wrapper element.
childrenThe children element.
labelThe label element.
checkboxThe selection checkbox element.

Methods ​

MethodDescription
setShowCheckbox(value: boolean): void
setDraggable(value: boolean, handleOnly: unknown): voidCalled by flint-rich-tree-view to set drag enabled state.