Use a different color for profile header action button vs confirmation dialog
I've got some really nice black on white background buttons in my navigation (see attached photo).
I need to add a confirmation dialog to one of them. However, the confirmation dialog uses the same styling and looks horrible (see attached photo).
Is it possible to have ->color('secondary') on the button but ->color('warning') on the dialog?


Solution:Jump to solution
<?php
namespace App\Filament\Resources\UserResource\Pages;
use App\Filament\Resources\UserResource;...
16 Replies
You mean set this to color:warning

yeah
and the Confirm button
Here is an example from another action

Okay, possible
But if this is an Image, it's no impossible.

it's an svg served by filament
Then you can set color to warning.
how?
just a min
I will share the code from my project.
use Filament\Actions\Action;
use Filament\Support\Enums\ActionSize;
Action::make('resetPassword')
->label('Reset password')
->icon('heroicon-o-exclamation-triangle')
->color('warning')
->requiresConfirmation()
->modalIcon('heroicon-o-exclamation-triangle')
->modalIconColor('warning')
->modalHeading('Reset password')
->modalDescription('Are you sure you would like to do this?')
->modalSubmitActionLabel('Confirm')
->modalSubmitActionColor('warning')
->modalCancelActionLabel('Cancel')
->action(function ($record) {
/////////////
/////////////
});
try this
Oooh ->modalIconColor('warning') !! Thanks
And nothing any problems?
That's great thanks. Unfortunately ->modalSubmitActionColor('warning') results in Method 'modalSubmitActionColor' not found in \Filament\Actions\Action - presumably you're not on Filament 4?
What is your version?
v4.1.10
What's your version?
Solution
<?php
namespace App\Filament\Resources\UserResource\Pages;
use App\Filament\Resources\UserResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
class ListUsers extends ListRecords
{
protected static string $resource = UserResource::class;
protected function getTableActions(): array
{
return [
Actions\Action::make('resetPassword')
->label('Reset password')
->icon('heroicon-o-exclamation-triangle')
->color('warning')
->requiresConfirmation()
->modalIcon('heroicon-o-exclamation-triangle')
->modalIconColor('warning')
->modalHeading('Reset password')
->modalDescription('Are you sure you want to reset this user's password?')
->modalSubmitActionLabel('Confirm')
->modalCancelActionLabel('Cancel')
->modalActions([
Actions\Action::make('submit')
->label('Confirm')
->color('warning') // Here we set the color of the confirm button
->submit(),
Actions\Action::make('cancel')
->label('Cancel')
->color('gray') // The cancel button color
->cancel(),
])
->action(function ($record): void {
// Here you can perform your reset logic for the specific user
$record->update(['password' => bcrypt('new-password')]);
// Optionally, send a notification
// Notification::make()
// ->title('Password for ' . $record->name . ' has been reset.')
// ->success()
// ->send();
}),
];
}
}
try this
Brilliant I can get it working from that, thank you!
Note: ->modelActions() is deprecated, but in this scenario it works for me.