filament/actions
Filament Actions adds reusable, customizable UI actions to Filament admin panels. Define buttons, modals, confirmations, and forms with a fluent API, then run callbacks, validations, and notifications consistently across tables, resources, and pages.
Installation
composer require filament/actions
Publish the config (if needed):
php artisan vendor:publish --provider="Filament\Actions\ActionsServiceProvider" --tag="actions-config"
First Action Add an action to a Livewire component:
use Filament\Actions\Action;
public function getActions(): array
{
return [
Action::make('delete')
->label('Delete Record')
->icon('heroicon-o-trash')
->action(fn () => $this->deleteRecord()),
];
}
Triggering the Action
Use the actions() method in your Livewire blade template:
<x-filament::actions :actions="$this->getActions()" />
Action::make('edit') with a form input to modify a record without a full page reload.Conditional Actions Disable actions based on state:
Action::make('export')
->visible(fn () => $this->record->isExportable())
->disabled(fn () => $this->isProcessing),
Action Groups Organize related actions (e.g., "Bulk Actions"):
ActionGroup::make([
Action::make('archive'),
Action::make('share'),
])->label('Bulk Actions'),
Dynamic Actions Fetch actions from a database or API:
public function getActions(): array
{
return Action::make('custom')
->label('Dynamic Action')
->url(fn () => route('dynamic.action', $this->record))
->openUrlInNewTab();
}
Form-Based Actions
Use Action::make('create') with form() to collect input:
Action::make('update-status')
->form([
TextInput::make('status')->required(),
])
->action(fn (array $data) => $this->updateStatus($data['status'])),
Table, Resource, or custom Livewire components.Filament\Resources\Resource to add actions to tables/views:
public static function table(Table $table): Table
{
return $table->actions([
Action::make('view'),
Action::make('edit'),
]);
}
<x-filament::actions :actions="$actions" @action-confirmed.window="customLogic" />
Action Registration Timing
getActions() is called after $this->record is set (e.g., in mount() or hydrate()).booted() if the component isn’t fully initialized.Form Submission Quirks
->defer() for actions that require async processing to prevent UI blocking.->action(fn (array $data) => $this->process($data))
->after(function () { $this->dispatch('refresh'); }),
Modal Overlays
Modal component). Use ->modal() explicitly if needed:
Action::make('confirm')->modalContent(fn () => view('custom.modal'));
Action Not Showing? Check:
visible() conditions (e.g., fn () => auth()->check()).<x-filament::actions />).Form Data Not Submitting? Verify:
form() fields are properly defined (e.g., TextInput::make()).->action() (not ->url()) for form submissions.Custom Modal Views Override the default modal template:
@push('filament.actions.scripts')
<script>
document.addEventListener('filament-action-modal-opened', (e) => {
console.log('Custom logic here', e.detail);
});
</script>
@endpush
Action Metadata Add metadata for frontend logic:
Action::make('export')
->extraAttributes(['data-testid' => 'export-action']),
Server-Side Logic
Extend Filament\Actions\Contracts\HasActions for reusable action logic:
class CustomActions implements HasActions {
public function getActions(): array { ... }
}
How can I help you explore Laravel packages today?