Imagine you have a table Action that you want to show ONLY when a certain filter is applied. For example, let's show the Restore action only when the "Show deleted records" filter is applied.
In the visible()
method, we can inject the table from a HasTable
and get the status of a filter using the getTableFilterState()
method.
use Filament\Tables; Tables\Actions\RestoreAction::make() ->visible(fn (Tables\Contracts\HasTable $livewire): bool => $livewire->getTableFilterState('trashed')['value'] === '0'),
And that's it. Only when a filter is applied will the action be visible.
A few of our Premium Examples: