Skip to content

Instantly share code, notes, and snippets.

@gigabites19
Created June 8, 2025 11:09
Show Gist options
  • Save gigabites19/e43a7e2ba5c751a2ccd823ff440b0a45 to your computer and use it in GitHub Desktop.
Save gigabites19/e43a7e2ba5c751a2ccd823ff440b0a45 to your computer and use it in GitHub Desktop.
FilamentPHP column header help tooltip
<?php
namespace App\Providers;
use Filament\Tables\Columns\Column;
use Illuminate\Support\HtmlString;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*/
public function boot(): void
{
/**
* As of now, FilamentPHP only has tooltip support for the actual cell,
* not for the header. This is a way to get help-tooltip for table headers.
*/
Column::macro('headerTooltip', function (?string $tooltip = null) {
/** @var Column $this */
$label = $this->getLabel();
$this->label(new HtmlString(
<<<HTML
<span
style="cursor: help; text-decoration-line: underline; text-decoration-style: dashed;"
x-tooltip.raw="$tooltip"
>
$label
</span>
HTML));
// Returning the object so other commands can be chained
return $this;
});
}
}
<?php
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
class ModelResource extends Resource
{
public static function table(Table $table): Table
{
return $table
->columns([
// can be used with any type of column
Tables\Columns\ToggleColumn::make('enabled')
->headerTooltip('Whether the resource is enabled')
// other commmands can be chained
->disabled(),
Tables\Columns\TextColumn::make('phone_number')
->headerTooltip('Phone number to send a notification to when an action happens'),
]);
}
}
@gigabites19
Copy link
Author

If anyone knows of a minimally intrusive way to achieve autocompletion for this I'd like to know. I want to avoid extending filament classes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment