© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
5 replies
dyo

closure in badgeColumn colors

I want to set the color success when the column value contains string of 'online'.

the value of column status is generated from api.

i tried below code, but i got error because of $record data is null..

BadgeColumn::make('status')
    ->formatStateUsing(fn ($record) => $this->getStatus($record->license))
    ->colors([
        'warning' => static fn ($record): bool => strpos($this->getStatus($record->license), 'logout') !== false,
        'success' => static fn ($record): bool => strpos($this->getStatus($record->license), 'online') !== false,
    ]),
BadgeColumn::make('status')
    ->formatStateUsing(fn ($record) => $this->getStatus($record->license))
    ->colors([
        'warning' => static fn ($record): bool => strpos($this->getStatus($record->license), 'logout') !== false,
        'success' => static fn ($record): bool => strpos($this->getStatus($record->license), 'online') !== false,
    ]),

what should i do?
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

BadgeColumn -> colors not displaying properly
FilamentFFilament / ❓┊help
3y ago
use $record in badgeColumn visibility
FilamentFFilament / ❓┊help
3y ago
Passing closure in viewData
FilamentFFilament / ❓┊help
2y ago
Use same icon for different state in BadgeColumn
FilamentFFilament / ❓┊help
3y ago