Tree is a standalone component driven by typed node data.

tree.ts
import { KuiTree, type KuiTreeNode } from '@kikita-labs/ui';

Provide stable node ids and bind selected or checked state from signals.

src
main.ts
styles
<div class="basic-tree-example">
  <kui-tree
    ariaLabel="Project files"
    [data]="nodes"
    [(value)]="selectedId"
    [(expandedIds)]="expandedIds"
  />
</div>

Use display mode for navigation and checkable mode for multi-select hierarchies.

  • Checkable mode cascades checked state to non-disabled descendants.
  • Partially checked parents expose mixed state when descendants differ.
  • Lazy nodes call loadChildren once on first expansion and cache the result.
  • Built-in icons are limited to folder and file; very large trees are not virtualized.

Set defaults.tree once for the application or for a subtree. Each option resolves as local input > defaults.tree.<option> > built-in default.

import { provideKikitaUi } from '@kikita-labs/ui';

export const appConfig: ApplicationConfig = {
  providers: [
    provideKikitaUi({
      defaults: {
        tree: {
          /* options below */
        },
      },
    }),
  ],
};
NameTypeDefaultDescription
size'xs' | 'sm' | 'md' | 'lg' — Component size. Takes precedence over the global defaults.size.
mode'display' | 'checkable' — Default mode.
disclosureIconKuiIconGlyph — Icon of the expand control. Takes precedence over defaults.icons.disclosure. See Structural Icons.

Set any of these on the component or an ancestor to restyle one part. Each token is optional: when it is not set, the part uses the role or scale token in the default column.

NameTypeDefaultDescription
--kui-tree-row-colorCSS custom property--kui-color-textRow color
--kui-tree-row-focus-ring-colorCSS custom property--kui-color-focusRow focus ring color
--kui-tree-spinner-track-colorCSS custom property--kui-color-surface-sunkenSpinner track color
--kui-tree-spinner-colorCSS custom property--kui-color-primary-indicatorSpinner color
NameTypeDefaultDescription
--kui-tree-row-gapCSS custom property--kui-space-2Row gap
--kui-tree-row-padding-inlineCSS custom property--kui-space-2Row padding, inline
--kui-tree-label-font-sizeCSS custom property--kui-text-sm-sizeLabel font size
--kui-tree-label-font-size-smCSS custom property--kui-text-xs-sizeLabel font size, sm
--kui-tree-label-font-size-lgCSS custom property--kui-text-base-sizeLabel font size, lg
--kui-tree-toggle-sizeCSS custom property20px (16px sm, 24px lg)Toggle and spacer size
--kui-tree-icon-sizeCSS custom property16px (14px sm, 18px lg)Node icon size
--kui-tree-spinner-sizeCSS custom property14pxLoading spinner size

Every text the component owns (accessible names, visible words, announcements) is a typed message with an English default. Override it for the application with provideKikitaUi({ messages }), or for a subtree with provideKuiMessages.

NameTypeDefaultDescription
labelstring — Accessible name of the tree when ariaLabel is not set. Default Tree.

Inputs verified against @kikita-labs/ui v2.0.0 public typings and package docs.

NameTypeDefaultDescription
mode'display' | 'checkable' | undefinedundefinedSelects navigation-style rows or checkbox rows with cascade. Falls back to defaults.tree.mode, then display.
size'xs' | 'sm' | 'md' | 'lg' | undefinedundefinedControls row height and label scale; only sm, md and lg have dedicated styling. Falls back to defaults.tree.size, then the root size, then md.
datareadonly KuiTreeNode[][]Root nodes rendered by the tree.
ariaLabelstring | undefinedundefinedAccessible name for the role="tree" container. Falls back to the tree.label message (Tree).
mobilebooleanfalseIncreases toggle hit targets to support touch layouts.
[(value)]string | nullnullControlled selected node id in display mode.
[(selected)]string | nullnullDeprecated alias for value, kept in sync with it. Use value instead; planned for removal in the next major version.
[(checkedIds)]string[][]Controlled checked node ids in checkable mode.
[(expandedIds)]string[][]Controlled expanded node ids.
loadChildren(node: KuiTreeNode) => Promise<readonly KuiTreeNode[]>-Lazy child loader called once for nodes marked lazy.
KuiTreeNode.icon'folder' | 'file'-Optional built-in glyph. Custom icon templates are not implemented.
KuiTreeOptionsinterface-Shape of defaults.tree: size, mode and disclosureIcon.

Tree uses ARIA tree semantics with roving tabindex keyboard navigation.

  • Set ariaLabel when nearby text does not already name the tree.
  • Arrow keys, Home, End, Enter, Space, and type-ahead move through visible nodes.
  • Disabled nodes stay reachable by navigation but cannot be selected or checked.
  • The root is role="tree" and nodes are role="treeitem" with aria-expanded, aria-selected (display) or aria-checked (checkable, including mixed), and aria-level, aria-setsize and aria-posinset. Exactly one node is in the tab order (roving tabindex).
  • Without ariaLabel the tree is named by the tree.label message.
  • Use mobile mode where touch targets need the larger 44px toggle affordance.

Consumer-visible changes of @kikita-labs/ui 2.0 for Tree.

  • The component class is KuiTree; the Component suffix is gone.
  • Size and mode defaults moved to provideKuiDefaults({ tree: { size, mode } }), together with the disclosureIcon glyph; the inputs are now undefined until set.
  • The default ariaLabel comes from the tree.label message.
  • Row, spinner and focus colours have tokens, plus gap, padding, font-size and icon-size geometry tokens.