F
Filament17mo ago
Tieme

navigation badge icon

Hi All, Is it possible to add a icon to the navigation badge? I want a icon insted of a number or text so it will show me if there is a timetracker active or not. public static function getNavigationBadge(): ?string { if(static::getModel()::where('stopped_at', null)->wherenot('started_at',null)->count() > 0) { //return static::getModel()::where('stopped_at', null)->wherenot('started_at',null)->count(); return 'heroicon-m-clock'; } return null; } Thanks for your help on this one!
No description
8 Replies
Anish
Anish13mo ago
Did you solve the issue?
Tieme
TiemeOP13mo ago
@Anish Nope, did not solve this.
awcodes
awcodes13mo ago
Try
return Blade::render(@svg(‘heroicon-m-clock’, ‘w-4 h-4’));
return Blade::render(@svg(‘heroicon-m-clock’, ‘w-4 h-4’));
Basically you can’t just pass in an icon string and expect it to output the icon if it’s not getting parsed into an icon.
Tieme
TiemeOP13mo ago
@awcodes i don't think it is possible. it will only accept strings en returns the HTML string from blade
No description
LeandroFerreira
LeandroFerreira13mo ago
https://github.com/filamentphp/filament/blob/3.x/packages/panels/resources/views/components/sidebar/item.blade.php
<x-filament::badge :color="$badgeColor">
{{ $badge }}
</x-filament::badge>
<x-filament::badge :color="$badgeColor">
{{ $badge }}
</x-filament::badge>
The badge is escaped. {!! $badge !!} will work and I think you could send a PR.
GitHub
filament/packages/panels/resources/views/components/sidebar/item.bl...
A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS. - filamentphp/filament
Anish
Anish13mo ago
Can this blade view be published and extended in the project?
Dennis Koch
Dennis Koch13mo ago
It can. But you should be careful with publishing views as soon as there are updates
Anish
Anish13mo ago
Yes, of course!

Did you find this page helpful?