cannot show icon

cannot show icon
9 Replies
torriv
torriv3y ago
try:
Tables\Columns\IconColumn::make('email_verified_at')
->boolean()
->trueIcon('heroicon-o-clock')
->falseIcon('heroicon-o-check-circle'),
Tables\Columns\IconColumn::make('email_verified_at')
->boolean()
->trueIcon('heroicon-o-clock')
->falseIcon('heroicon-o-check-circle'),
meeglos
meeglos3y ago
Did the answer solve your issue?
Mazz
Mazz3y ago
I have the same issue
IconColumn::make('External')
->icon(fn(string $state): string => match ($state) {
'draft' => 'heroicon-o-pencil',
'reviewing' => 'heroicon-o-clock',
'published' => 'heroicon-o-check-circle',
default => 'heroicon-o-pencil',
})
->label('Link'),
IconColumn::make('External')
->icon(fn(string $state): string => match ($state) {
'draft' => 'heroicon-o-pencil',
'reviewing' => 'heroicon-o-clock',
'published' => 'heroicon-o-check-circle',
default => 'heroicon-o-pencil',
})
->label('Link'),
Tried with this code. Note - the External column does not exists. Worked in 2.x @hainguyen8610 i solved it by setting a State. Since External does not exist it might be an issue if it is null
IconColumn::make('external')
->icon('heroicon-o-arrow-top-right-on-square')
->state('random')
->label('Link'),
IconColumn::make('external')
->icon('heroicon-o-arrow-top-right-on-square')
->state('random')
->label('Link'),
But it seems if we have null values the Column doesn't render at all
Dennis Koch
Dennis Koch3y ago
That's correct
Mazz
Mazz3y ago
Is this a desired behaviour? Because in my case i'd like to render a Icon or Badges if the value is null. Tried with ->state(null) and ->default(null) but with the same outcome. If desired: How could i let this render?
Dennis Koch
Dennis Koch3y ago
I guess it is. I hit the same issue already. I think I mapped null state to some unused value like -1 @Dan Harrin Any reason we filter null values in table columns? As sometimes it's desired to format null as a placeholder or fallback icon?
Dan Harrin
Dan Harrin3y ago
imagine this
IconColumn::make('email_verified_at')
->icon('heroicon-o-check')
IconColumn::make('email_verified_at')
->icon('heroicon-o-check')
maybe someone should add placeholderIcon() to the icon column where you can pass in an icon for the null state
Dennis Koch
Dennis Koch3y ago
Not sure. You expcet this to show an icon when the value is not null? I think this query should be formatted or at least cast to a bool inside getStateUsing()
Arnaud
Arnaud2y ago
Hello, if it could helps, juste use default : ->default(false). In my case :

IconColumn::make('calendar_id')
->label('With meeting ?')
->boolean()
->icon('heroicon-o-calendar')
->default(false)
->falseColor('gray'),

IconColumn::make('calendar_id')
->label('With meeting ?')
->boolean()
->icon('heroicon-o-calendar')
->default(false)
->falseColor('gray'),
Also works with column relationship exists 🙂

Did you find this page helpful?