How can I render the badge with only the icon (no text)?

Tables\Columns\TextColumn::make('transaction.state')
->label('State')
->badge()
->color(fn (string $state): string => match ($state) {
'created' => 'info',
'pending' => 'info',
'completed' => 'success',
'declined' => 'danger',
'failed' => 'danger',
'reverted' => 'info',
})
->icon(fn (string $state): string => match ($state) {
'created' => 'heroicon-o-clock',
'pending' => 'heroicon-o-clock',
'completed' => 'heroicon-o-check',
'declined' => 'heroicon-o-x',
'failed' => 'heroicon-o-x',
'reverted' => 'heroicon-o-arrow-path',
})
->formatStateUsing(fn (string $state): string => '')
Tables\Columns\TextColumn::make('transaction.state')
->label('State')
->badge()
->color(fn (string $state): string => match ($state) {
'created' => 'info',
'pending' => 'info',
'completed' => 'success',
'declined' => 'danger',
'failed' => 'danger',
'reverted' => 'info',
})
->icon(fn (string $state): string => match ($state) {
'created' => 'heroicon-o-clock',
'pending' => 'heroicon-o-clock',
'completed' => 'heroicon-o-check',
'declined' => 'heroicon-o-x',
'failed' => 'heroicon-o-x',
'reverted' => 'heroicon-o-arrow-path',
})
->formatStateUsing(fn (string $state): string => '')
If I set the state value to '', the badge disappears completely. Is there any way to force it to be visible (->visible() didn't work i tried)?
2 Replies
ruski
ruskiOP2w ago
oh, perfect
Want results from more Discord servers?
Add your server