© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
5 replies
Carlos

Conditionally rendering an icon in TextColumn

I have a situation where the value of a cell could be "true" or anything else. How can I render an icon instead of text in a TextColumn, I tried this but it didn't work:
Tables\Columns\TextColumn::make('value')
    ->formatStateUsing( fn($state) => $state === 'true' ? new HtmlString(Blade::render('<x-filament::icon icon="heroicon-o-check" class="w-4 h-4"/>')) : $state ),
Tables\Columns\TextColumn::make('value')
    ->formatStateUsing( fn($state) => $state === 'true' ? new HtmlString(Blade::render('<x-filament::icon icon="heroicon-o-check" class="w-4 h-4"/>')) : $state ),


Thanks!
Solution
ahh ok. Use
TextColumn::make('value')->icon(fn($record) => $record->value === 'true' ? 'heroicon-o-check' : null)
TextColumn::make('value')->icon(fn($record) => $record->value === 'true' ? 'heroicon-o-check' : null)
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

TextColumn->icon() disabled by formatStateUsing()
FilamentFFilament / ❓┊help
3y ago
conditionally disable <x-filament::icon-button>
FilamentFFilament / ❓┊help
3y ago
Enum TextColumn badge() with label, icon and color
FilamentFFilament / ❓┊help
3y ago
Error in searchable TextColumn
FilamentFFilament / ❓┊help
13mo ago