PHPackages                             mrshanebarron/tree-view - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. mrshanebarron/tree-view

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mrshanebarron/tree-view
=======================

Tree view component for Laravel - supports Livewire and Vue

v1.0.3(5mo ago)011MITBladePHP ^8.1

Since Dec 14Pushed 4mo agoCompare

[ Source](https://github.com/mrshanebarron/tree-view)[ Packagist](https://packagist.org/packages/mrshanebarron/tree-view)[ RSS](/packages/mrshanebarron-tree-view/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (1)Versions (5)Used By (0)

Tree View
=========

[](#tree-view)

Hierarchical tree structure component for Laravel applications. Supports nested items, expand/collapse, selection, and custom icons. Works with Livewire and Vue 3.

Installation
------------

[](#installation)

```
composer require mrshanebarron/tree-view
```

Livewire Usage
--------------

[](#livewire-usage)

### Basic Usage

[](#basic-usage)

```
@php
$items = [
    [
        'id' => 'src',
        'label' => 'src',
        'icon' => 'folder',
        'children' => [
            ['id' => 'app', 'label' => 'App.vue', 'icon' => 'file'],
            ['id' => 'main', 'label' => 'main.js', 'icon' => 'file'],
        ]
    ],
    ['id' => 'readme', 'label' => 'README.md', 'icon' => 'file'],
];
@endphp

```

### With Default Expanded

[](#with-default-expanded)

```

```

### Selectable Items

[](#selectable-items)

```

```

### With Icons

[](#with-icons)

```

```

### Livewire Props

[](#livewire-props)

PropTypeDefaultDescription`items`array`[]`Tree structure array`expanded`array`[]`IDs of initially expanded nodes`selectable`boolean`false`Enable item selection`showIcons`boolean`true`Show folder/file icons### Item Structure

[](#item-structure)

```
$items = [
    [
        'id' => 'unique-id',       // Required: unique identifier
        'label' => 'Display Name', // Required: visible text
        'icon' => 'folder',        // Optional: 'folder' or 'file'
        'children' => [            // Optional: nested items
            ['id' => 'child-1', 'label' => 'Child Item', 'icon' => 'file'],
        ],
    ],
];
```

### Events

[](#events)

```

```

Vue 3 Usage
-----------

[](#vue-3-usage)

### Setup

[](#setup)

```
import { SbTreeView } from './vendor/sb-tree-view';
app.component('SbTreeView', SbTreeView);
```

### Basic Usage

[](#basic-usage-1)

```

const items = [
  {
    id: 'docs',
    label: 'Documents',
    icon: 'folder',
    children: [
      { id: 'resume', label: 'Resume.pdf', icon: 'file' },
    ]
  }
];

```

### With Selection

[](#with-selection)

```

function handleSelect(id) {
  console.log('Selected:', id);
}

```

### Vue Props

[](#vue-props)

PropTypeDefaultDescription`items`Array`[]`Tree items`expanded`Array`[]`Expanded node IDs`selectable`Boolean`false`Enable selection`showIcons`Boolean`true`Show icons### Events

[](#events-1)

EventPayloadDescription`selected`stringEmitted when item is selected`expanded`stringEmitted when node is expanded`collapsed`stringEmitted when node is collapsedUse Cases
---------

[](#use-cases)

### File Explorer

[](#file-explorer)

```
$items = $this->buildFileTree(base_path());

private function buildFileTree(string $path): array
{
    $items = [];
    foreach (scandir($path) as $file) {
        if ($file === '.' || $file === '..') continue;

        $fullPath = $path . '/' . $file;
        $item = [
            'id' => $fullPath,
            'label' => $file,
            'icon' => is_dir($fullPath) ? 'folder' : 'file',
        ];

        if (is_dir($fullPath)) {
            $item['children'] = $this->buildFileTree($fullPath);
        }

        $items[] = $item;
    }
    return $items;
}
```

### Category Browser

[](#category-browser)

```
$items = Category::with('children')
    ->whereNull('parent_id')
    ->get()
    ->map(fn($cat) => $this->categoryToTreeItem($cat))
    ->toArray();

private function categoryToTreeItem($category): array
{
    return [
        'id' => (string) $category->id,
        'label' => $category->name,
        'icon' => $category->children->count() ? 'folder' : 'file',
        'children' => $category->children->map(
            fn($c) => $this->categoryToTreeItem($c)
        )->toArray(),
    ];
}
```

### Organization Chart

[](#organization-chart)

```
$items = [
    [
        'id' => 'ceo',
        'label' => 'CEO',
        'icon' => 'folder',
        'children' => [
            [
                'id' => 'cto',
                'label' => 'CTO',
                'icon' => 'folder',
                'children' => [
                    ['id' => 'dev1', 'label' => 'Developer 1', 'icon' => 'file'],
                    ['id' => 'dev2', 'label' => 'Developer 2', 'icon' => 'file'],
                ]
            ],
            ['id' => 'cfo', 'label' => 'CFO', 'icon' => 'file'],
        ]
    ]
];
```

Styling
-------

[](#styling)

The tree view includes:

- Indented nested levels
- Expand/collapse chevron icons
- Folder and file icons
- Selection highlight
- Hover effects

Requirements
------------

[](#requirements)

- PHP 8.1+
- Laravel 10, 11, or 12
- Tailwind CSS 3.x
- Alpine.js

License
-------

[](#license)

MIT License

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance74

Regular maintenance activity

Popularity5

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

152d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7a38dc9b4ccc180ee3e9df8879f8747ea9dbf36812c6546827fe504fa8993eb8?d=identicon)[mrshanebarron](/maintainers/mrshanebarron)

### Embed Badge

![Health badge](/badges/mrshanebarron-tree-view/health.svg)

```
[![Health](https://phpackages.com/badges/mrshanebarron-tree-view/health.svg)](https://phpackages.com/packages/mrshanebarron-tree-view)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[orchestra/canvas

Code Generators for Laravel Applications and Packages

21017.2M158](/packages/orchestra-canvas)[illuminate/pipeline

The Illuminate Pipeline package.

9446.6M213](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10532.5M862](/packages/illuminate-pagination)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[spatie/laravel-mix-preload

Add preload and prefetch links based your Mix manifest

169176.0k2](/packages/spatie-laravel-mix-preload)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
