Navegação

VTreeNavigation

Componente11 exemplos13 propsA2UI · TreeNavigation

Explorador hierárquico expansível para file systems, settings, documentação e qualquer conteúdo nested.

Importação
<script setup lang="ts">
import { VTreeNavigation } from 'vueui-nova-kit'
</script>

Uso

Exemplo
<script setup lang="ts">
import { VTreeNavigation } from 'vueui-nova-kit'
</script>

<template>
  <VTreeNavigation size="md" variant="file" showCounts active="vueui-nova" />
</template>

Playground

Os controles abaixo são gerados a partir das props declaradas em VTreeNavigation.types.ts; o código acompanha cada mudança.

Exemplos

Variantes, tamanhos e estados, extraídos das stories da biblioteca.

Default

Variação Padrão. Estado padrão do componente; use a aba Controls para experimentar as props ao vivo.

Ver código
vue
<script setup lang="ts">
import { VTreeNavigation } from 'vueui-nova-kit'

const items = [
  {
    key: 'workspace',
    label: 'Workspace',
    icon: 'folder',
    count: 12,
    children: [
      {
        key: 'projects',
        label: 'Projects',
        icon: 'folder',
        count: 8,
        children: [
          {
            key: 'vueui-nova',
            label: 'vueui-nova',
            icon: 'folder',
            count: 3,
          },
          {
            key: 'marketing',
            label: 'marketing',
            icon: 'folder',
            count: 2,
          },
          {
            key: 'design-system',
            label: 'design-system',
            icon: 'folder',
            count: 3,
          },
        ],
      },
      { key: 'resources', label: 'Resources', icon: 'folder' },
      {
        key: 'documentation',
        label: 'Documentation',
        icon: 'book',
        children: [
          {
            key: 'getting-started',
            label: 'Getting Started',
            icon: 'doc',
          },
          {
            key: 'components',
            label: 'Components',
            icon: 'doc',
            count: 24,
          },
          { key: 'guides', label: 'Guides', icon: 'doc', count: 12 },
          {
            key: 'changelog',
            label: 'Changelog',
            icon: 'doc',
            count: 5,
          },
        ],
      },
    ],
  },
  { key: 'trash', label: 'Trash', icon: 'trash', count: 4 },
]
</script>

<template>
  <VTreeNavigation :items="items" active="vueui-nova" />
</template>

File Tree

Variação File Tree. Props: variant="file", active="work".

Ver código
vue
<script setup lang="ts">
import { VTreeNavigation } from 'vueui-nova-kit'

const items = [
  {
    key: 'documents',
    label: 'Documents',
    icon: 'folder',
    children: [
      { key: 'photos', label: 'Photos', icon: 'folder' },
      { key: 'work', label: 'Work', icon: 'folder' },
    ],
  },
  { key: 'notes', label: 'Notes.txt', icon: 'file' },
]
const expandedKeys = ['documents']
</script>

<template>
  <VTreeNavigation
    :items="items"
    active="work"
    :expanded-keys="expandedKeys" />
</template>

Settings Tree

Variação Settings Tree. Props: variant="settings", active="appearance", showCounts=false.

Ver código
vue
<script setup lang="ts">
import { VTreeNavigation } from 'vueui-nova-kit'

const items = [
  {
    key: 'appearance',
    label: 'Appearance',
    icon: 'settings',
  },
  {
    key: 'notifications',
    label: 'Notifications',
    icon: 'settings',
  },
  { key: 'privacy', label: 'Privacy', icon: 'settings' },
  { key: 'advanced', label: 'Advanced', icon: 'settings' },
]
</script>

<template>
  <VTreeNavigation
    variant="settings"
    :show-counts="false"
    :items="items"
    active="appearance" />
</template>

Documentation Tree

Variação Documentation Tree. Props: variant="documentation", active="components", showCounts=false.

Ver código
vue
<script setup lang="ts">
import { VTreeNavigation } from 'vueui-nova-kit'

const items = [
  {
    key: 'introduction',
    label: 'Introduction',
    icon: 'book',
  },
  { key: 'components', label: 'Components', icon: 'book' },
  { key: 'guides', label: 'Guides', icon: 'book' },
  {
    key: 'api-reference',
    label: 'API Reference',
    icon: 'book',
  },
]
</script>

<template>
  <VTreeNavigation
    variant="documentation"
    :show-counts="false"
    :items="items"
    active="components" />
</template>

Simple Tree

Variação Simple Tree. Props: variant="simple", active="home", showCounts=false.

Ver código
vue
<script setup lang="ts">
import { VTreeNavigation } from 'vueui-nova-kit'

const items = [
  { key: 'home', label: 'Home', icon: 'home' },
  { key: 'about', label: 'About', icon: 'star' },
  { key: 'services', label: 'Services', icon: 'star' },
  { key: 'contact', label: 'Contact', icon: 'contact' },
]
</script>

<template>
  <VTreeNavigation
    variant="simple"
    :show-counts="false"
    :items="items"
    active="home" />
</template>

Small

Variação Pequeno. Props: size="sm".

Ver código
vue
<script setup lang="ts">
import { VTreeNavigation } from 'vueui-nova-kit'

const items = [
  {
    key: 'workspace',
    label: 'Workspace',
    icon: 'folder',
    count: 12,
    children: [
      {
        key: 'projects',
        label: 'Projects',
        icon: 'folder',
        count: 8,
        children: [
          {
            key: 'vueui-nova',
            label: 'vueui-nova',
            icon: 'folder',
            count: 3,
          },
          {
            key: 'marketing',
            label: 'marketing',
            icon: 'folder',
            count: 2,
          },
          {
            key: 'design-system',
            label: 'design-system',
            icon: 'folder',
            count: 3,
          },
        ],
      },
      { key: 'resources', label: 'Resources', icon: 'folder' },
      {
        key: 'documentation',
        label: 'Documentation',
        icon: 'book',
        children: [
          {
            key: 'getting-started',
            label: 'Getting Started',
            icon: 'doc',
          },
          {
            key: 'components',
            label: 'Components',
            icon: 'doc',
            count: 24,
          },
          { key: 'guides', label: 'Guides', icon: 'doc', count: 12 },
          {
            key: 'changelog',
            label: 'Changelog',
            icon: 'doc',
            count: 5,
          },
        ],
      },
    ],
  },
  { key: 'trash', label: 'Trash', icon: 'trash', count: 4 },
]
</script>

<template>
  <VTreeNavigation size="sm" :items="items" active="vueui-nova" />
</template>

Large

Variação Grande. Props: size="lg".

Ver código
vue
<script setup lang="ts">
import { VTreeNavigation } from 'vueui-nova-kit'

const items = [
  {
    key: 'workspace',
    label: 'Workspace',
    icon: 'folder',
    count: 12,
    children: [
      {
        key: 'projects',
        label: 'Projects',
        icon: 'folder',
        count: 8,
        children: [
          {
            key: 'vueui-nova',
            label: 'vueui-nova',
            icon: 'folder',
            count: 3,
          },
          {
            key: 'marketing',
            label: 'marketing',
            icon: 'folder',
            count: 2,
          },
          {
            key: 'design-system',
            label: 'design-system',
            icon: 'folder',
            count: 3,
          },
        ],
      },
      { key: 'resources', label: 'Resources', icon: 'folder' },
      {
        key: 'documentation',
        label: 'Documentation',
        icon: 'book',
        children: [
          {
            key: 'getting-started',
            label: 'Getting Started',
            icon: 'doc',
          },
          {
            key: 'components',
            label: 'Components',
            icon: 'doc',
            count: 24,
          },
          { key: 'guides', label: 'Guides', icon: 'doc', count: 12 },
          {
            key: 'changelog',
            label: 'Changelog',
            icon: 'doc',
            count: 5,
          },
        ],
      },
    ],
  },
  { key: 'trash', label: 'Trash', icon: 'trash', count: 4 },
]
</script>

<template>
  <VTreeNavigation size="lg" :items="items" active="vueui-nova" />
</template>

Multiple

Variação Múltiplo. Props: multiple=true.

Ver código
vue
<script setup lang="ts">
import { VTreeNavigation } from 'vueui-nova-kit'

const items = [
  {
    key: 'workspace',
    label: 'Workspace',
    icon: 'folder',
    count: 12,
    children: [
      {
        key: 'projects',
        label: 'Projects',
        icon: 'folder',
        count: 8,
        children: [
          {
            key: 'vueui-nova',
            label: 'vueui-nova',
            icon: 'folder',
            count: 3,
          },
          {
            key: 'marketing',
            label: 'marketing',
            icon: 'folder',
            count: 2,
          },
          {
            key: 'design-system',
            label: 'design-system',
            icon: 'folder',
            count: 3,
          },
        ],
      },
      { key: 'resources', label: 'Resources', icon: 'folder' },
      {
        key: 'documentation',
        label: 'Documentation',
        icon: 'book',
        children: [
          {
            key: 'getting-started',
            label: 'Getting Started',
            icon: 'doc',
          },
          {
            key: 'components',
            label: 'Components',
            icon: 'doc',
            count: 24,
          },
          { key: 'guides', label: 'Guides', icon: 'doc', count: 12 },
          {
            key: 'changelog',
            label: 'Changelog',
            icon: 'doc',
            count: 5,
          },
        ],
      },
    ],
  },
  { key: 'trash', label: 'Trash', icon: 'trash', count: 4 },
]
const active = ['vueui-nova', 'components']
</script>

<template>
  <VTreeNavigation :items="items" :active="active" multiple />
</template>

Disabled

Variação Desabilitado. Props: disabled=true.

Ver código
vue
<script setup lang="ts">
import { VTreeNavigation } from 'vueui-nova-kit'

const items = [
  {
    key: 'workspace',
    label: 'Workspace',
    icon: 'folder',
    count: 12,
    children: [
      {
        key: 'projects',
        label: 'Projects',
        icon: 'folder',
        count: 8,
        children: [
          {
            key: 'vueui-nova',
            label: 'vueui-nova',
            icon: 'folder',
            count: 3,
          },
          {
            key: 'marketing',
            label: 'marketing',
            icon: 'folder',
            count: 2,
          },
          {
            key: 'design-system',
            label: 'design-system',
            icon: 'folder',
            count: 3,
          },
        ],
      },
      { key: 'resources', label: 'Resources', icon: 'folder' },
      {
        key: 'documentation',
        label: 'Documentation',
        icon: 'book',
        children: [
          {
            key: 'getting-started',
            label: 'Getting Started',
            icon: 'doc',
          },
          {
            key: 'components',
            label: 'Components',
            icon: 'doc',
            count: 24,
          },
          { key: 'guides', label: 'Guides', icon: 'doc', count: 12 },
          {
            key: 'changelog',
            label: 'Changelog',
            icon: 'doc',
            count: 5,
          },
        ],
      },
    ],
  },
  { key: 'trash', label: 'Trash', icon: 'trash', count: 4 },
]
</script>

<template>
  <VTreeNavigation :items="items" active="vueui-nova" disabled />
</template>

Loading

Variação Carregando. Props: loading=true.

Ver código
vue
<script setup lang="ts">
import { VTreeNavigation } from 'vueui-nova-kit'

const items = [
  {
    key: 'workspace',
    label: 'Workspace',
    icon: 'folder',
    count: 12,
    children: [
      {
        key: 'projects',
        label: 'Projects',
        icon: 'folder',
        count: 8,
        children: [
          {
            key: 'vueui-nova',
            label: 'vueui-nova',
            icon: 'folder',
            count: 3,
          },
          {
            key: 'marketing',
            label: 'marketing',
            icon: 'folder',
            count: 2,
          },
          {
            key: 'design-system',
            label: 'design-system',
            icon: 'folder',
            count: 3,
          },
        ],
      },
      { key: 'resources', label: 'Resources', icon: 'folder' },
      {
        key: 'documentation',
        label: 'Documentation',
        icon: 'book',
        children: [
          {
            key: 'getting-started',
            label: 'Getting Started',
            icon: 'doc',
          },
          {
            key: 'components',
            label: 'Components',
            icon: 'doc',
            count: 24,
          },
          { key: 'guides', label: 'Guides', icon: 'doc', count: 12 },
          {
            key: 'changelog',
            label: 'Changelog',
            icon: 'doc',
            count: 5,
          },
        ],
      },
    ],
  },
  { key: 'trash', label: 'Trash', icon: 'trash', count: 4 },
]
</script>

<template>
  <VTreeNavigation :items="items" active="vueui-nova" loading />
</template>

Lazy Children

Variação Lazy Children. Props: lazy=true, active="root".

Ver código
vue
<script setup lang="ts">
import { VTreeNavigation } from 'vueui-nova-kit'

const items = [
  {
    key: 'root',
    label: 'Raiz (carrega filhos ao expandir)',
    lazy: true,
    children: [],
  },
]
</script>

<template>
  <VTreeNavigation :items="items" active="root" lazy />
</template>

Acessibilidade

  • role="tree" no container, role="treeitem" nos nós
  • aria-expanded, aria-selected, aria-level
  • Teclado: Arrow keys, Enter, Space, Home, End
  • Foco visível com --v-tree-focus-ring-*
  • Suporta seleção single e multiple (aria-multiselectable)

Estados

Collapsed · Expanded · Hover · Focus-visible · Selected · Disabled · Loading (lazy children)

Motion

TriggerPropertyDurationEasing
Expandheight/opacity/chevron200msease-out
Collapseheight/opacity/chevron200msease-in
Hoverbackground200msease-out
Focusoutline200msease-out

Respeitar prefers-reduced-motion.

Todas as transições respeitam prefers-reduced-motion e os tokens --v-duration-*.

Props

PropTipoDefaultDescrição
activestring | string[]——
expandedKeysstring[]——
itemsVTreeNavigationItem[]——
multiplebooleanfalse—
showCountsbooleantrue—
iconFieldstring"icon"—
lazybooleanfalse—
loadChildren(node: VTreeNavigationItem) => Promise<VTreeNavigationItem[]>
((node: VTreeNavigationItem) => Promise<VTreeNavigationItem[]>)
——
disabledbooleanfalse—
loadingbooleanfalse—
sizeVTreeNavigationSize"md"—
variantVTreeNavigationVariant | 'default' | 'primary' | 'subtle'
"default" | "primary" | "subtle" | VTreeNavigationVariant
"file"—
ariaLabelstring——

Events

EventoPayloadDescrição
@update:activevalue: string | string[]—
@update:expandedKeysvalue: string[]—
@selectvalue: string | string[]—

Slots

SlotProps do slot
#default—

Fonte: src/components/navigation/VTreeNavigation/VTreeNavigation.vue · tipos: src/components/navigation/VTreeNavigation/VTreeNavigation.types.ts