Hiding Table Column Labels

Sometimes I use an imageColumn of viewColumn as the leftmost column in a table. For this column I don't want a label. I noticed when setting a label with an empty string such as ->label('') the label is not shown however this automatically shows the column toggle menu (top right of table), which seems like an unintended side effect or maybe even a bug. I can properly hide a label with:
ViewColumn::make('buyer_color')
->label(new HtmlString(' '))
ViewColumn::make('buyer_color')
->label(new HtmlString(' '))
But that seems strange. Anyone know if filament has a better way of hiding a table column label without showing the toggle menu button?
Solution:
@bionary Should be fixed with this PR: https://github.com/filamentphp/filament/pull/18386
GitHub
Dont show colum manager for blank columns without column groups by ...
Background: When column lables are blank and inside a column group, isToggleable() needs to evaluate to true for that column so that, even though the label is hidden in the manager, when the column...
Jump to solution
10 Replies
Mohamed Ayaou
Mohamed Ayaou3w ago
Filament doesn't show a toggle button by default I guess that you have set all columns to be toggleable by default in a service provider somewhere if that's the case, then just use ->toggleable(false) for your specific column
bionary
bionaryOP3w ago
I don't have have toggleable() on in a service provider. It is strange. If I go to any table and make any table column element have ->label('') the toggle columns menu button appears.
Dennis Koch
Dennis Koch3w ago
I don't think that should be the case. Can you reproduce this on a fresh install?
bionary
bionaryOP3w ago
Hi Dennis, Just did a fresh install, added one user, then created resource for Users; nothing else. That toggle shows up when using empty string as label. (perhaps a bug?)
#UserResource

namespace App\Filament\Resources\Users\Tables;

use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;

class UsersTable
{
public static function configure(Table $table): Table
{
return $table
->columns([
TextColumn::make('name')
->label('')
->searchable(),
TextColumn::make('email')
->label('Email address')
->searchable(),
TextColumn::make('email_verified_at')
->dateTime()
->sortable(),
TextColumn::make('created_at')
->dateTime()
->sortable(),
TextColumn::make('updated_at')
->dateTime()
->sortable(),
]);
}
}
#UserResource

namespace App\Filament\Resources\Users\Tables;

use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;

class UsersTable
{
public static function configure(Table $table): Table
{
return $table
->columns([
TextColumn::make('name')
->label('')
->searchable(),
TextColumn::make('email')
->label('Email address')
->searchable(),
TextColumn::make('email_verified_at')
->dateTime()
->sortable(),
TextColumn::make('created_at')
->dateTime()
->sortable(),
TextColumn::make('updated_at')
->dateTime()
->sortable(),
]);
}
}
bionary
bionaryOP3w ago
No description
bionary
bionaryOP3w ago
FYI: I went to some older version 3 apps and this does not appear to happen. It seems v4 specific.
Dennis Koch
Dennis Koch3w ago
Interesting. Does it only show with empty labels? Or do all columns show up? Can you open a bug report on GitHub, please?
Kenneth Sese
Kenneth Sese3w ago
@bionary I was able to reproduce this and know where the issue is coming from. I have some other column manager issues to take care of so I'll add this to the list. In the meantime if you need a quick solution you can add ->columnManager(false) to your table and it will force hide the column manager.
Solution
Kenneth Sese
Kenneth Sese3w ago
@bionary Should be fixed with this PR: https://github.com/filamentphp/filament/pull/18386
GitHub
Dont show colum manager for blank columns without column groups by ...
Background: When column lables are blank and inside a column group, isToggleable() needs to evaluate to true for that column so that, even though the label is hidden in the manager, when the column...
bionary
bionaryOP3w ago
Wow! You're fast! Thank you.

Did you find this page helpful?