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?
No description
No description
Solution:
<?php namespace App\Filament\Resources\UserResource\Pages; use App\Filament\Resources\UserResource;...
Jump to solution
16 Replies
LiveMatters
LiveMatters6d ago
You mean set this to color:warning
No description
keiron
keironOP5d ago
yeah and the Confirm button
keiron
keironOP5d ago
Here is an example from another action
No description
LiveMatters
LiveMatters5d ago
Okay, possible
LiveMatters
LiveMatters5d ago
But if this is an Image, it's no impossible.
No description
keiron
keironOP5d ago
it's an svg served by filament
LiveMatters
LiveMatters5d ago
Then you can set color to warning.
keiron
keironOP5d ago
how?
LiveMatters
LiveMatters5d ago
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
keiron
keironOP5d ago
Oooh ->modalIconColor('warning') !! Thanks
LiveMatters
LiveMatters5d ago
And nothing any problems?
keiron
keironOP5d ago
That's great thanks. Unfortunately ->modalSubmitActionColor('warning') results in Method 'modalSubmitActionColor' not found in \Filament\Actions\Action - presumably you're not on Filament 4?
LiveMatters
LiveMatters5d ago
What is your version?
keiron
keironOP5d ago
v4.1.10 What's your version?
Solution
LiveMatters
LiveMatters5d ago
<?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
keiron
keironOP5d ago
Brilliant I can get it working from that, thank you! Note: ->modelActions() is deprecated, but in this scenario it works for me.

Did you find this page helpful?