PHP code example of harvirsidhu / filament-action-overflow

1. Go to this page and download the library: Download harvirsidhu/filament-action-overflow library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

harvirsidhu / filament-action-overflow example snippets


use Filament\Actions\Action;
use Filament\Actions\ActionGroup;

public function getHeaderActions(): array
{
    return ActionGroup::make([
        Action::make('edit'),
        Action::make('archive'),
        Action::make('delete'),
    ])->withOverflow(); // keep 1 primary, overflow the rest
}

ActionGroup::make([...])->withOverflow(2);
ActionGroup::make([...])->withSplit();

use Filament\Actions\Action;
use Harvirsidhu\FilamentActionOverflow\Facades\ActionOverflow;

return ActionOverflow::make([
    Action::make('edit'),
    Action::make('archive'),
    Action::make('delete'),
])
    ->primaryCount(2)
    ->label('Options')
    ->icon('heroicon-m-bars-3')
    ->color('gray')
    ->toActions();

// More: tuck the extras away
ActionGroup::make([$edit, $archive, $delete])->withOverflow();

// Split: one action and its variants
ActionGroup::make([$callNext, $toCounterOne, $toCounterTwo])->withSplit();

ActionGroup::make([...])->withOverflow(2);          // macro
ActionOverflow::make([...])->primaryCount(2)->toActions(); // builder

use Filament\Support\Enums\IconPosition;
use Filament\Support\Icons\Heroicon;

ActionOverflow::make($actions)
    ->label(__('Manage'))                      // trigger text, used as given
    ->icon(Heroicon::EllipsisVertical)         // string | BackedEnum | Filament icon enum
    ->iconPosition(IconPosition::Before)       // 'before' | 'after' | IconPosition enum
    ->color('danger')                          // any Filament color name
    ->hiddenLabel()                            // icon-only trigger (where supported)
    ->toActions();

use Harvirsidhu\FilamentActionOverflow\Enums\MorePosition;

ActionOverflow::make($actions)
    ->morePosition(MorePosition::Start) // or the string 'start'
    ->toActions();

ActionOverflow::make([
    Action::make('callNext'),
    Action::make('counterOne')->label('Counter 1'),
    Action::make('counterTwo')->label('Counter 2'),
])
    ->split()
    ->toActions();

ActionOverflow::make($actions)
    ->dropdownPlacement('bottom-start')
    ->toActions();

use Filament\Actions\Action;
use Filament\Actions\ActionGroup;

return ActionGroup::make([
    Action::make('submit'),

    ActionGroup::make([
        Action::make('discount'),
        Action::make('tax'),
        Action::make('rounding'),
    ])->dropdown(false),

    ActionGroup::make([
        Action::make('change-billing'),
        Action::make('refresh'),
    ])->dropdown(false),
])->withOverflow(1);

ActionOverflow::make([
    Action::make('edit')->hidden(),          // dropped
    Action::make('archive'),                 // kept
    Action::make('delete')->visible(false),  // dropped
    Action::make('publish'),                 // kept
])->toActions();

ActionOverflow::make($actions)
    ->filterUnauthorized()
    ->toActions();

public function getHeaderActions(): array
{
    return ActionOverflow::make([
        Action::make('publish')->visible(fn (Post $record): bool => $record->isDraft()),
        Action::make('edit'),
        Action::make('delete'),
    ])
        ->livewire($this)
        ->toActions();

    // or: ActionGroup::make([...])->livewire($this)->withOverflow();
}

Action::make('publish')->visible(fn (?Post $record): bool => $record?->isDraft() ?? true)

ActionOverflow::make($actions)->button(false)->toActions();

// config/action-overflow.php
return [
    'primary_count'       => 2,
    'label'               => 'Manage',
    'more_position'       => 'start',
    'filter_unauthorized' => true,
    // ...
];

ActionGroup::make(array $actions)->withOverflow(?int $primary = null): array

ActionGroup::make(array $actions)->withSplit(): array

public function updatedActiveTab(): void
{
    parent::updatedActiveTab();

    $this->cachedHeaderActions = [];
    $this->cacheInteractsWithHeaderActions();
}
bash
php artisan vendor:publish --tag="filament-action-overflow-config"
bash
php artisan vendor:publish --tag="filament-action-overflow-translations"