Copied to clipboard on suffix action
- Published: 08 Apr 2024 Updated: 08 Aug 2026
Custom copy action, click the icon to copy the content
1use Filament\Forms\Components\Actions\Action;
2
3Forms\Components\TextInput::make('copyContent')
4 ->suffixAction(
5 Action::make('copy')
6 ->icon('heroicon-s-clipboard-document-check')
7 ->action(function ($livewire, $state) {
8 $livewire->js(
9 'window.navigator.clipboard.writeText("'.$state.'");
10 $tooltip("'.__('Copied to clipboard').'", { timeout: 1500 });'
11 );
12 })
13 ),
Related Tricks:
Bring the sticky actions back form filament v2
Unrequire fields recursively when saving as draft
Let Users to Select All Options with a Simple Hint Action
Sometimes, when we need to test our application locally, we always have to fill forms manually. Let's take the Filament approach and achieve this with more accurate data.
Translating components can often be a repetitive task, Fortunately, there's a neat trick to automate this process, making your components instantly translatable.