F
Filamentβ€’8mo ago
Dushmanta

How can I keep an icon in the column label instead of text in the table?

I'm trying to implement a table, and in one column, I want an icon instead of a text label. Can anyone help me with this? Thank you.
Solution:
```php TextColumn::make('status') ->label(view('test-dummy')) ...
Jump to solution
8 Replies
LeviBeezy
LeviBeezyβ€’8mo ago
According to the docs, you might want the Icon Column for Tables https://filamentphp.com/docs/3.x/tables/columns/icon
Dushmanta
DushmantaOPβ€’8mo ago
IconColumn::make('plus')
->icon('heroicon-o-plus')
IconColumn::make('plus')
->icon('heroicon-o-plus')
I've done that like this but in the label Plus shows but I want the icon to appear
LeviBeezy
LeviBeezyβ€’8mo ago
IconColumn::make('status')
->icon('heroicon-o-plus')
->color(fn (string $state): string => match ($state) {
'Default' => 'secondary',
'Subscribed' => 'success',
'Unsubscribed' => 'danger',
'Engaged' => 'success',
'Inactive' => 'warning',
'Bounced' => 'warning',
'Complaint' => 'danger',
'Pending Verification' => 'info',
})
->toggleable(true),
IconColumn::make('status')
->icon('heroicon-o-plus')
->color(fn (string $state): string => match ($state) {
'Default' => 'secondary',
'Subscribed' => 'success',
'Unsubscribed' => 'danger',
'Engaged' => 'success',
'Inactive' => 'warning',
'Bounced' => 'warning',
'Complaint' => 'danger',
'Pending Verification' => 'info',
})
->toggleable(true),
No description
LeviBeezy
LeviBeezyβ€’8mo ago
I have a field 'status' in my model
Dushmanta
DushmantaOPβ€’8mo ago
Yes! I want an icon instead of that Status text, so I'm wondering if it's possible.
Solution
dissto
disstoβ€’8mo ago
TextColumn::make('status')
->label(view('test-dummy'))

// test-dummy.blade.php
<x-filament::icon icon="heroicon-o-user" class="w-5 h-5"/>
TextColumn::make('status')
->label(view('test-dummy'))

// test-dummy.blade.php
<x-filament::icon icon="heroicon-o-user" class="w-5 h-5"/>
Or as an alternative approach without a view
TextColumn::make('status')
->label(function () {
return new HtmlString(Blade::render('<x-filament::icon icon="heroicon-o-user" class="w-5 h-5" />'));
})
TextColumn::make('status')
->label(function () {
return new HtmlString(Blade::render('<x-filament::icon icon="heroicon-o-user" class="w-5 h-5" />'));
})
Thats one way. But please have accessibility in mind πŸ’ͺ
dissto
disstoβ€’8mo ago
No description
Dushmanta
DushmantaOPβ€’8mo ago
Woahh! That worked, Thanks a lot. 🀜 πŸ€› both worked πŸ™‚ Thanks a lot @dissto I really appreciate the help πŸ™‚
Want results from more Discord servers?
Add your server