> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pharen.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Tree

> Import and use the Tree components from @pharen/ui.

export const PharenUiPreview = ({name, title = 'Pharen UI component preview'}) => <div className="not-prose my-6 overflow-hidden rounded-xl border border-gray-200 bg-white shadow-sm dark:border-white/10 dark:bg-zinc-950">
    <div className="pharen-ui-preview-root" data-pharen-ui-preview data-example={name} role="region" aria-label={title} />
  </div>;

Use **Tree** to build an action or navigation pattern. This page covers every Vue component exported by the public module.

<PharenUiPreview name="tree" title="Tree preview" />

<Accordion title="View code">
  ```vue theme={null}
  <script setup lang="ts">
  import { Tree, TreeItem, TreeItemLabel } from '@pharen/ui';

  type Node = { id: string; label: string; children?: Node[] };
  const items: Node[] = [
    { id: 'workspace', label: 'Workspace', children: [
      { id: 'documents', label: 'Documents' },
      { id: 'workflows', label: 'Workflows', children: [{ id: 'published', label: 'Published' }] },
    ] },
  ];
  </script>

  <template>
    <Tree :items="items" :get-key="node => node.id" :get-children="node => node.children" :default-expanded="['workspace', 'workflows']" class="w-full max-w-sm">
      <template #default="{ flattenItems }">
        <TreeItem v-for="item in flattenItems" :key="item.value.id" v-bind="item.bind" :value="item.value" :level="item.level">
          <TreeItemLabel>{{ item.value.label }}</TreeItemLabel>
        </TreeItem>
      </template>
    </Tree>
  </template>
  ```
</Accordion>

## Installation

<CodeGroup>
  ```bash npm theme={null}
  npm install @pharen/ui
  ```

  ```bash pnpm theme={null}
  pnpm add @pharen/ui
  ```

  ```bash yarn theme={null}
  yarn add @pharen/ui
  ```

  ```bash bun theme={null}
  bun add @pharen/ui
  ```
</CodeGroup>

<Note>
  Import `@pharen/ui/styles.css` exactly once in your application entrypoint.
</Note>

## Usage

```ts theme={null}
import { Tree, TreeDragLine, TreeItem, TreeItemLabel } from '@pharen/ui';
```

## Exports

| Export          | Purpose                                  |
| --------------- | ---------------------------------------- |
| `Tree`          | Exported Vue component from this module. |
| `TreeDragLine`  | Exported Vue component from this module. |
| `TreeItem`      | Represents one item.                     |
| `TreeItemLabel` | Labels a value or region.                |

## Source

[Open the source on GitHub](https://github.com/PharenIT/ELEV8-Labs/tree/main/src/packages/ui/src/components/tree)
