Introduction
Actions are interactive UI components that handle user workflows in your Filament application. Unlike traditional PHP action classes that only handle business logic, Filament actions combine UI elements (buttons, modals, forms) with the logic that executes when users interact with them.
For example, you might have a button to delete a client record that opens a confirmation modal. When the user confirms, the client is deleted. This entire workflow is an action:
use Filament\Actions\Action;
Action::make('delete')
->requiresConfirmation()
->action(fn () => $this->client->delete())
How actions work
Actions are built using a fluent API that allows you to configure every aspect of the user experience:
Simple URL-based actions
The simplest actions redirect users to a URL when clicked:
use Filament\Actions\Action;
Action::make('edit')
->url(fn (): string => route('posts.edit', ['post' => $this->post]))
Actions with modals
Actions can open modals to collect additional information before executing:
use Filament\Actions\Action;
use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\TextInput;
use Illuminate\Support\Facades\Mail;
Action::make('sendEmail')
->schema([
TextInput::make('subject')->required(),
RichEditor::make('body')->required(),
])
->action(function (array $data) {
Mail::to($this->client)
->send(new GenericEmail(
subject: $data['subject'],
body: $data['body'],
));
})
Actions with confirmation
For destructive operations, you can require user confirmation:
use Filament\Actions\Action;
Action::make('delete')
->requiresConfirmation()
->modalHeading('Delete post')
->modalDescription('Are you sure you\'d like to delete this post? This cannot be undone.')
->action(fn () => $this->post->delete())
Actions support four trigger styles:
Action::make('edit')
->button()
Action::make('edit')
->link()
Action::make('edit')
->icon('heroicon-m-pencil-square')
->iconButton()
Action::make('edit')
->badge()
Customize how your action appears to users:
Action::make('edit')
->label('Edit post')
->icon('heroicon-m-pencil-square')
->color('primary')
Actions come in three sizes:
use Filament\Support\Enums\Size;
Action::make('create')
->size(Size::Large)
Authorization
You can conditionally show or hide actions based on user permissions:
Action::make('edit')
->visible(auth()->user()->can('update', $this->post))
Action::make('edit')
->hidden(! auth()->user()->can('update', $this->post))
Using policies
Actions can automatically check Laravel policies:
Action::make('edit')
->authorize('update')
If the policy returns a response message, you can show it as a tooltip:
Action::make('edit')
->authorize('update')
->authorizationTooltip()
Or display it as a notification when clicked:
Action::make('edit')
->authorize('update')
->authorizationNotification()
Utility injection
Most action methods accept closures that can have utilities injected as parameters:
use Illuminate\Database\Eloquent\Model;
use Livewire\Component;
Action::make('edit')
->visible(function (Model $record, Component $livewire) {
return $livewire->user->can('update', $record);
})
Available utilities include $record, $data, $arguments, $livewire, $action, and more. The specific parameter names must be used for injection to work.
Additional features
Keyboard shortcuts
Bind keyboard shortcuts to your actions:
Action::make('save')
->action(fn () => $this->save())
->keyBindings(['command+s', 'ctrl+s'])
Badges
Add a badge to the corner of a button:
Action::make('filter')
->iconButton()
->icon('heroicon-m-funnel')
->badge(5)
->badgeColor('success')
Rate limiting
Prevent abuse by rate limiting actions:
Action::make('delete')
->rateLimit(5) // 5 attempts per minute
Add custom HTML attributes:
Action::make('edit')
->extraAttributes([
'title' => 'Edit this post',
'data-tooltip' => 'Click to edit',
])
Next steps
Discover how to use modals for confirmation, forms, and wizards in your actions.
Save time with Filament’s prebuilt actions for common operations like Create, Edit, and Delete.