passasooz/filament-tree-dropdown

A generic Filament custom dropdown component for tree structures (parent-child-grandchild).

Maintainers

Package info

github.com/passasooz/filament-tree-dropdown

Language:Blade

pkg:composer/passasooz/filament-tree-dropdown

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-04-10 08:19 UTC

This package is auto-updated.

Last update: 2026-04-10 08:23:29 UTC


README

A Filament component for tree-structured selection (parent → child → grandchild) with checkboxes. Supports single item selection, group selection and optional text search.

Installation

composer require passasooz/filament-tree-dropdown

Register the plugin in your Filament panel

In your PanelProvider (e.g. app/Providers/Filament/AdminPanelProvider.php), add the plugin inside the panel() method:

use Passasooz\FilamentTreeDropdown\FilamentTreeDropdownPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        // ... other configuration
        ->plugins([
            FilamentTreeDropdownPlugin::make(),
        ]);
}

Publish the view (optional)

To override the blade view in your project:

php artisan vendor:publish --tag="filament-tree-dropdown-views"

Usage

use Passasooz\FilamentTreeDropdown\Forms\Components\TreeDropdown;

Fluent builder

Use group() for group nodes and item() for leaf nodes. Methods are chainable and nesting levels are unlimited.

TreeDropdown::make('category')
    ->label('Category')
    ->group('Animals', function ($g) {
        $g->group('Mammals', function ($g) {
            $g->item('Dog', 'dog');
            $g->item('Cat', 'cat');
        });
        $g->group('Birds', function ($g) {
            $g->item('Stork', 'stork');
            $g->item('Parrot', 'parrot');
        });
    })
    ->group('Plants', function ($g) {
        $g->item('Rose', 'rose');
        $g->item('Oak', 'oak');
    })
    ->searchable()   // optional

Raw array

If your data is already structured (e.g. from a DB or API):

TreeDropdown::make('category')
    ->tree([
        [
            'label' => 'Animals',
            'children' => [
                ['label' => 'Dog', 'value' => 'dog'],
                ['label' => 'Cat', 'value' => 'cat'],
            ],
        ],
    ])
    ->searchable()

You can change the array keys if your data uses different names:

->labelKey('name')      // default: 'label'
->valueKey('id')        // default: 'value'
->childrenKey('items')  // default: 'children'

Options

Method Description
->searchable() Enables the search bar inside the dropdown
->searchable(false) Disables search (default)
->label('...') Field label and placeholder text

How search works

Search filters by substring on the item label (case-insensitive).

  • Query "stork" → shows all items whose label contains "stork"
  • Query "sto" → shows all items whose label contains "sto" (e.g. "Stork" is shown)
  • Parent groups are shown automatically if at least one child matches
  • Groups with no matching children are hidden

Selection behaviour

  • Leaf node: toggles the single value.
  • Group node: selects/deselects all descendant leaf nodes.
    • Checkbox is indeterminate when only some children are selected.
  • Groups can be expanded/collapsed with the arrow icon (only when search is inactive).

Development / customisation

  • Source files are in src/Forms/Components/.
  • The view is in resources/views/tree-dropdown.blade.php.
  • Publish the view with vendor:publish to override it in your project.