Icon Visibility on Text Column depending on record value

I have a Text Column with a modal where I'm showing an Icon and Text. I'm able to hide the text depending on the status of the $record->StatusID from the model by using formatStateUsing() but the icon still shows. Is there a way to make the display of the icon conditional?

See code below.


        Tables\Columns\TextColumn::make('tracking')
            ->action(Action::make('updateShipping')
                ->action(function (Model $record, array $data): void {
                    $record->ConfirmationNumber = $data['ConfirmationNumber'];
                    $record->StatusID = 3;
                    $record->save();
                    \Mail::to($record->EmailAddress)->send(new \App\Mail\TrackingNumber($record));
                })
                ->form([
                TextInput::make('ConfirmationNumber')
                    ->label('Delivery Confirmation #')
                    ->required(),
                ])
                    ->label(fn (Model $record) => "Order#: {$record->OrderID} - {$record->FirstName} {$record->LastName}")
                )
                ->icon('heroicon-o-truck')
                ->label('Tracking')
                ->alignCenter()
                ->formatStateUsing(function (Model $record): string {
                        return $record->StatusID == 5 ? 'SHIP' : '';
                    }),

Thank you!
Solution
sure, use a closure customization as well:
->icon(static fn (Model $record): string|null => $record->statusID === 5 ? 'heroicon-o-truck' : null)
Was this page helpful?