Install the package:
composer require shreejan/actionable-column
Publish assets (if customizing CSS):
php artisan vendor:publish --provider="Shreejan\ActionableColumn\ActionableColumnServiceProvider" --tag="actionable-column-assets"
(Optional: Create resources/css/actionable-column-custom.css for overrides without publishing.)
First use case:
Replace a static TextColumn or BadgeColumn with an actionable column in a Filament table:
use Shreejan\ActionableColumn\Tables\Columns\ActionableColumn;
use Filament\Actions\Action;
ActionableColumn::make('status')
->badge()
->color('success')
->tapAction(
Action::make('approve')
->label('Approve')
->action(fn ($record) => $record->update(['status' => 'approved']))
)
clickableColumn(), actionIconColor()).modal, requiresConfirmation).ActionableColumn::make('priority')
->badge()
->color('danger') // Red for high priority
->tapAction(
Action::make('markUrgent')
->label('Mark as Urgent')
->action(fn ($record) => $record->update(['priority' => 'high']))
);
Use when: You need a visual indicator (badge) with a single action (e.g., status, priority).
ActionableColumn::make('name')
->actionIcon(Heroicon::PencilSquare)
->actionIconColor('primary')
->tapAction(
Action::make('editName')
->label('Rename')
->modalContent(fn ($record) => view('filament.tables.actions.edit-name', ['record' => $record]))
);
Use when: The column displays text (e.g., name, title) and needs an action button alongside it.
ActionableColumn::make('title')
->clickableColumn()
->color('info')
->tapAction(
Action::make('viewDetails')
->label('View Details')
->url(fn ($record) => route('records.show', $record))
);
Use when: The entire column should trigger an action (e.g., row-level navigation).
ActionableColumn::make('tags')
->actionLabel('Add Tag')
->tapAction(
Action::make('addTag')
->label('Add Tag')
->form([
TextInput::make('name')->required(),
])
->action(fn ($record, array $data) => $record->tags()->attach($data['name']))
);
Use when: The column is empty, and you want to enable creation directly from the table.
Leverage Filament’s built-in actions for consistency:
use Filament\Actions\DeleteAction;
ActionableColumn::make('status')
->badge()
->tapAction(
DeleteAction::make()
->label('Deactivate')
->action(fn ($record) => $record->update(['active' => false]))
);
Use closures for dynamic action configurations:
ActionableColumn::make('created_at')
->formatStateUsing(fn ($state) => $state->diffForHumans())
->tapAction(
Action::make('revert')
->label('Revert Changes')
->visible(fn ($record) => $record->revisions_count > 0)
->action(fn ($record) => $record->revert())
);
Mix ActionableColumn with standard columns in a table:
Table::make(Post::class, [
Columns\IdColumn::make(),
ActionableColumn::make('published_at')
->badge()
->color('success')
->tapAction(Action::make('unpublish')),
Columns\TextColumn::make('title'),
]);
Extend styles without modifying published assets:
/* resources/css/actionable-column-custom.css */
.actionable-column-badge {
@apply bg-indigo-600 text-white;
}
.actionable-column-button {
@apply text-sm font-medium;
}
Filament Version Mismatch:
CSS Overrides Not Applying:
resources/css/ may not load if Filament’s asset pipeline doesn’t include it.resources/css/app.css:
@import 'actionable-column-custom';
ACTIONABLE_COLUMN_CUSTOM_CSS_PATH in .env:
ACTIONABLE_COLUMN_CUSTOM_CSS_PATH=resources/css/actionable-column-custom.css
Action Button Not Showing:
showActionIcon(false) is set or the action is hidden, the button may disappear.->visible() or ->can() conditions on the action.Clickable Column Conflicts:
clickableColumn() with other interactive columns (e.g., checkboxes) may cause unintended triggers.->clickableColumn(false) for specific cases.Empty State Logic:
null or empty. Customize this with:
->emptyStateActionLabel(fn ($record) => $record->id ? 'Add Related' : 'Create First')
Inspect Rendered HTML:
<div class="actionable-column">
<span class="actionable-column-badge">Approved</span>
<button class="actionable-column-button">...</button>
</div>
Check Action Registration:
getActions() method:
public static function getActions(): array {
return [
Action::make('approve')->label('Approve'),
];
}
Log Action Execution:
->action(fn ($record, array $data) => {
\Log::info('Action triggered for record ID:', [$record->id, $data]);
$record->update($data);
})
Clear Cached Views:
php artisan view:clear
Custom Action Types:
class CustomActionableColumn extends ActionableColumn {
public function tapCustomAction(CustomAction $action) { ... }
}
Additional Badge/Text Modes:
pill() method for rounded pill-style badges:
// In ActionableColumn.php
public function pill(): static {
$this->view = 'actionable-column::columns.pill';
return $this;
}
Dynamic Icons/Colors:
formatActionIconUsing() method to dynamically set icons based on record data:
ActionableColumn::make('status')
->formatActionIconUsing(fn ($record) => match($record->status) {
'pending' => Heroicon::Clock,
default => Heroicon::CheckCircle,
})
Bulk Action Integration:
bulkAction() method:
ActionableColumn::make('status')
->bulkAction(
Action::make('bulkApprove')
->action(fn (Collection $records) => $records->update(['status' => 'approved']))
)
color() is set, the badge/text uses Filament’s default colors (e.g., gray-500 for text).heroicon-o-pencil-squareHow can I help you explore Laravel packages today?