Skip to content

TreeMenu

TreeMenu component displays hierarchical navigation structures, commonly used in admin panel sidebar navigation.


Basic Usage

Pass menu configuration via :items prop. Supports icons, badges, and disabled states.

vue
<TTreeMenu :items="[
  { label: 'Dashboard', icon: IconHome, href: '#', active: true },
  { label: 'Projects', href: '#', badge: '3' },
  { label: 'Content', icon: IconFileText, children: [
    { label: 'Articles', href: '#' },
    { label: 'Categories', href: '#' },
  ]},
  { label: 'Users', href: '#' },
  { label: 'Settings', href: '#', disabled: true },
]" />

Multi-level Nesting & Active Highlight

Supports unlimited nesting depth. Setting active: true on a child item will recursively highlight all parent items. In the example below, "📄 All Articles" is active, and its parent chain "Content" → "Articles" is automatically highlighted.

vue
<TTreeMenu :items="[
  { label: 'Dashboard', icon: IconHome, href: '#' },
  { label: 'Content', icon: IconFileText, children: [
    { label: 'Articles', children: [
      { label: 'All Articles', href: '#', active: true },   ← currently active
      { label: 'Write', href: '#' },
    ]},
  ]},
]" v-model:expanded-keys="expandedKeys" />

Accordion Mode

accordion is true by default — only one parent node can be expanded at a time. Expanding a new node automatically collapses siblings.

vue
<TTreeMenu :items="items" accordion />

Expand All

Set default-expand-all to expand all parent nodes by default.

vue
<TTreeMenu :items="items" default-expand-all />

Dark Theme

Use with data-bs-theme="dark" for dark sidebar appearance.

vue
<aside class="navbar navbar-vertical" data-bs-theme="dark">
  <div class="container-fluid">
    <TTreeMenu :items="items" />
  </div>
</aside>

API

TTreeMenu Props

PropDescriptionTypeDefault
itemsTree menu dataTreeMenuItem[][]
accordionAccordion mode (only one sibling expanded)booleantrue
defaultExpandAllExpand all nodes by defaultbooleanfalse
expandedKeysExpanded node keys (v-model)(string | number)[][]
indentIndent per level (px)number16
collapsibleAllow collapsingbooleantrue

TTreeMenu Emits

EmitParametersDescription
update:expandedKeyskeys: (string | number)[]Expanded keys changed
selectitem: TreeMenuItemA leaf menu item selected
toggleitem: TreeMenuItem, expanded: booleanExpand/collapse state changed

TreeMenuItem

PropertyTypeDescription
labelstringDisplay text
iconComponentIcon component (@tabler/icons-vue)
hrefstringLink URL
targetstringLink target
activebooleanActive state (children's active cascades to parents)
disabledbooleanDisabled state
badgestring | { text, color }Badge (color is a bg-xxx class)
childrenTreeMenuItem[]Child menu items
keystring | numberCustom node key (for controlled expandedKeys)