Β© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filamentβ€’3y agoβ€’
2 replies
khairulazmi_

Set Tags Color base on database value

Hello everyone . I am trying to populate tags on table using badge and the color will base on database value .

Right now my solution was
 TextColumn::make('tag.name')
                    ->label('Tags')
                    ->badge()
                    ->color(function($state){
                        return Color::hex(Tag::where('name', $state)->first()->color);
                    }),
 TextColumn::make('tag.name')
                    ->label('Tags')
                    ->badge()
                    ->color(function($state){
                        return Color::hex(Tag::where('name', $state)->first()->color);
                    }),


Which I think can be improve , because I dont want to re querying Tag again ..

Thank you πŸ˜„
Screenshot_2024-01-31_at_3.34.25_PM.png
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

change background color for select column base on value
FilamentFFilament / β“β”Šhelp
3y ago
Color to spatie tags?
FilamentFFilament / β“β”Šhelp
3y ago
Using html() on a RichEditor-set value still rendering the tags
FilamentFFilament / β“β”Šhelp
3y ago
Displaying options base on selected value
FilamentFFilament / β“β”Šhelp
3y ago