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:
Thanks!
Solution:Jump to solution
ahh ok. Use
TextColumn::make('value')->icon(fn($record) => $record->value === 'true' ? 'heroicon-o-check' : null)
3 Replies
Thanks for your response, as far I know, the IconColumn displays "only" icons, in this case I only need to render the icon when the value is "true", if the value is "Dog", "Apple" or "House" I need to display the String
Solution
ahh ok. Use
TextColumn::make('value')->icon(fn($record) => $record->value === 'true' ? 'heroicon-o-check' : null)