Filament: Custom Title or Description in Action Confirmation Dialog

Free Snippet

When dealing with confirmation modals - it is important to customize the message. You can do that with a callback when using Filament Actions.

FilamentExamples ThumbBase (5)

How it works

When dealing with Actions in Filament, you might have seen ->requiresConfirmation() added like this:

Tables\Actions\Action::make('Set as Default')
->hidden(fn($record) => $record->is_default)

What if we want to add a custom message to the confirmation dialog? We can do that by adding a closure to the requiresConfirmation() method like this:

Tables\Actions\Action::make('Set Default')
->hidden(fn($record) => $record->is_default)
->requiresConfirmation(function (Tables\Actions\Action $action, $record) {
$action->modalDescription('Are you sure you want to set this as the default pipeline stage?');
$action->modalHeading('Set "' . $record->name . '" as Default');
return $action;

You can set whatever message you want and even use the record data to make it more dynamic.

This example is based on our Customer Management CRM

A few of our Premium Examples: