geekstek/filament-tree
Composer 安装命令:
composer require geekstek/filament-tree
包简介
Tree form components for Filament v4
README 文档
README
A Filament v4 plugin that provides tree form components including a cascading tree selector (Wunderbaum style) and a dropdown tree select.
Requirements
- PHP 8.2+
- Filament 4.0+
- Laravel 11+
Installation
composer require geekstek/filament-tree
The package will auto-register via Laravel's package discovery.
Components
1. Tree (Cascading Tree Selector)
A flat tree component with checkbox selection and cascade behavior - when you select a parent, all children are automatically selected.
use Geekstek\FilamentTree\Forms\Components\Tree; Tree::make('permissions') ->label('Permissions') ->helperText('Click on a parent to select all children') ->options([ [ 'id' => 1, 'label' => 'System', 'children' => [ ['id' => 2, 'label' => 'Users'], ['id' => 3, 'label' => 'Roles'], ['id' => 4, 'label' => 'Settings'], ], ], [ 'id' => 5, 'label' => 'Content', 'children' => [ ['id' => 6, 'label' => 'Posts'], ['id' => 7, 'label' => 'Pages'], ], ], ]) ->disabledOptions([3]) // Disable specific node IDs ->live() // Enable reactive updates ->columnSpanFull()
Available Methods
| Method | Description |
|---|---|
options(array|Closure $options) |
Set the tree data structure |
disabledOptions(array|Closure $ids) |
Disable specific node IDs (they won't be selected when parent is clicked) |
showToolbar(bool|Closure $show) |
Show/hide the expand/collapse toolbar |
hideToolbar() |
Hide the toolbar |
defaultExpanded(bool|Closure $expanded) |
Set default expanded state |
collapsed() |
Start with all nodes collapsed |
expandSelected(bool|Closure $expand) |
Expand nodes that contain selected items |
defaultOpenLevel(int|Closure $level) |
Set default expand level (0 = all collapsed, 1 = first level, etc.) |
maxHeight(string|int|Closure $height) |
Set max height of the tree container (e.g., '400px', '50vh', 300) |
Height Control Example
// Limit tree height to show approximately 10 rows Tree::make('permissions') ->options($options) ->maxHeight('360px') // ~36px per row × 10 rows // Use viewport height Tree::make('permissions') ->options($options) ->maxHeight('50vh') // Using integer (will be converted to pixels) Tree::make('permissions') ->options($options) ->maxHeight(400)
2. TreeSelect (Dropdown Tree)
A dropdown component with tree structure support, powered by TreeselectJS.
use Geekstek\FilamentTree\Forms\Components\TreeSelect; TreeSelect::make('category_id') ->label('Category') ->placeholder('Select a category...') ->options([ [ 'value' => 1, 'name' => 'Electronics', 'children' => [ ['value' => 2, 'name' => 'Phones'], ['value' => 3, 'name' => 'Laptops'], ], ], [ 'value' => 4, 'name' => 'Clothing', 'children' => [ ['value' => 5, 'name' => 'Men'], ['value' => 6, 'name' => 'Women'], ], ], ]) ->required()
Available Methods
| Method | Description |
|---|---|
options(array|Closure $options) |
Set the tree data (supports both id/label and value/name formats) |
disabledOptions(array|Closure $ids) |
Disable specific node IDs |
single(bool|Closure $isSingle) |
Enable single select mode |
showTags(bool|Closure $show) |
Show selected items as tags |
clearable(bool|Closure $clearable) |
Allow clearing selection |
searchable(bool|Closure $searchable) |
Enable search functionality |
placeholder(string|Closure $placeholder) |
Set placeholder text |
expandSelected(bool|Closure $expand) |
Expand nodes that contain selected items |
defaultOpenLevel(int|Closure $level) |
Set default expand level (0 = all collapsed, 1 = first level, etc.) |
maxHeight(string|int|Closure $height) |
Set max height of the dropdown list (e.g., '300px', '50vh', 250) |
Height Control Example
// Limit dropdown height TreeSelect::make('category_id') ->options($options) ->maxHeight('250px') // For large datasets TreeSelect::make('category_id') ->options($largeDataset) ->maxHeight('400px') ->searchable() // Enable search for easier navigation
3. TreeEntry (Infolist Display)
Display tree data in infoolists with selected items highlighted.
use Geekstek\FilamentTree\Infolists\Components\TreeEntry; TreeEntry::make('permissions') ->label('Assigned Permissions') ->options([ [ 'id' => 1, 'label' => 'System', 'children' => [ ['id' => 2, 'label' => 'Users'], ['id' => 3, 'label' => 'Roles'], ], ], ]) ->collapsed() // Start collapsed
Available Methods
| Method | Description |
|---|---|
options(array|Closure $options) |
Set the tree data structure |
defaultExpanded(bool|Closure $expanded) |
Set default expanded state |
collapsed() |
Start with all nodes collapsed |
maxHeight(string|int|Closure $height) |
Set max height of the tree display (e.g., '400px', '50vh', 300) |
Data Structure
Tree & TreeEntry
The Tree and TreeEntry components expect data in this format:
[
[
'id' => 1, // Unique identifier
'label' => 'Node 1', // Display text
'children' => [ // Optional nested children
[
'id' => 2,
'label' => 'Child 1',
],
],
],
]
TreeSelect
The TreeSelect component uses TreeselectJS format:
[
[
'value' => 1, // Unique identifier
'name' => 'Node 1', // Display text
'children' => [ // Optional nested children
[
'value' => 2,
'name' => 'Child 1',
],
],
],
]
Features
- ✅ Full Filament v4 compatibility
- ✅ Inherits all standard Field methods (
label(),helperText(),required(),live(), etc.) - ✅ Dark mode support
- ✅ Cascade selection (select parent → auto-select children)
- ✅ Individual node disabling
- ✅ Expand/collapse all functionality
- ✅ Select all / Deselect all
- ✅ Alpine.js powered (no jQuery dependency)
License
MIT License. See LICENSE for more information.
geekstek/filament-tree 适用场景与选型建议
geekstek/filament-tree 是一款 基于 Blade 开发的 Composer 扩展包,目前已累计 246 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 12 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「tree」 「laravel」 「filament」 「tree-select」 「cascading-select」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 geekstek/filament-tree 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 geekstek/filament-tree 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 geekstek/filament-tree 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
jsTree widget for yii2
Doctrine2 behavior traits - slowhop fork
A fast and dynamic Merkle tree implementation
Data structure collections, helpers and utilities for yii2 ActiveRecord models(trees, sorts and etc.)
Yii2 DynaTree Menu widget uses Dynamic tree view control jquery.dynatree.js
JQuery ZTree Yii2
统计信息
- 总下载量: 246
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 18
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-12-15

