F
Filamentβ€’8mo ago
Ian_X12

For IconColumn, only show boolean icon when true?

Hi there, I have an icon column (see screenshot) but I only want an icon to display when the value is true. How can I do this?
No description
6 Replies
Dennis Koch
Dennis Kochβ€’8mo ago
What's your code? Probably using ->boolean()? Try something like this: ->icon(fn ($state) => $state ? 'your-icon' : null)
Ian_X12
Ian_X12OPβ€’8mo ago
This is the result: Associated code:
IconColumn::make('is_default')
->label('Default')
->boolean()
->icon(fn ($state) => $state ? 'heroicon-o-check' : null),
IconColumn::make('is_default')
->label('Default')
->boolean()
->icon(fn ($state) => $state ? 'heroicon-o-check' : null),
No description
Dennis Koch
Dennis Kochβ€’8mo ago
No need for ->boolean()
Ian_X12
Ian_X12OPβ€’8mo ago
Removing ->boolean() results in the same visual appearance.
Dennis Koch
Dennis Kochβ€’8mo ago
Can you try ->falseIcon(null)? Not sure where that default false Icon is coming from πŸ€” I think ->icon() should be all you need πŸ€”
Ian_X12
Ian_X12OPβ€’8mo ago
->falseIcon(null) did not change the visual appearance I don't know where it's coming from either 😰
Want results from more Discord servers?
Add your server