Created
June 8, 2025 11:09
-
-
Save gigabites19/e43a7e2ba5c751a2ccd823ff440b0a45 to your computer and use it in GitHub Desktop.
FilamentPHP column header help tooltip
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
}); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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'), | |
]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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