Using components outside filament
Hi,
in V2 it was possible to use filament components outside filament, which could be done by also using the filament.base layout.
But in V3, this base layout now needs $livewire to be passed through. How can I do this outside filament? I looked inside filament itself and didn't quite understand where $livewire even comes from, as it is used in the base layout, which is the first thing that gets loaded (I guess?)
Thank you!
Solution:Jump to solution
Then i'm just changing the colors in a service provider.
```php
if (! Filament::isServing()) {
FilamentColor::register([
'primary' => '#00529b',...
24 Replies
And in Livewire v3, livewire is auto loaded
the thing is, I want to use these components for error pages like 5xx.blade.php or 404.blade.php
But if I use the filament components they all have the default color (yellow), because (I think) the context of the current panel is missing. I tried to set up my auth template like filament does in the base layout. But I'm still getting the default color even though I replaced the whole layout head with the head of the base filament layout (for testing).
If I debug the current panel, it's the default one, which is what I want, but still it doesn't use the correct color for 'primary'.
Do you have an idea?
Current layout:
if you have a repo, i'd be happy to look at it, but this looks ok to me.
not atm. Any tips on how I can debug this?
sorry, I'd have to see more of the setup.
compared it with my login view (which is loaded through the panel), but with the same layout. The only difference is, that the primary root color is set differently in the <style> head tag...
But I don't know why 😂
seems like the ColorManager in
@filamentStyles
messes something upnot sure. I'm using the compoents outside of Filament completely and the only thing i'm doing different is calling the asset manager styles directly.
do you use a custom viteTheme as well or are the colors only registerd in the PanelProvider?
Solution
Then i'm just changing the colors in a service provider.
ohh, that did the trick!
i have a custom vite theme, but only because i'm not inside Filament any more, so I have to have a different stylesheet
but for me, it's still a bit weird. Why is the primary color the default, if the panel has a custom one?
Because, if I debug the current panel in the view with filament()->getCurrentPanel() it's the correct one and I can see the correct colors as array inside the dump.
not sure.
is there a nicer why to grab these colors from the panel instead of duplicating my primary color in the service provider? They are the same.
so, can I access the panel somehow in the condition?
i think the problem is that your error pages aren't getting loaded through Filament
which makes sense
sure, makes sense. But can I access these colors from the panel class?
but if you have them on the panel then you can probably get them from the panel in the service provider so you don't have to duplicate them. Something along these lines. Might not be the right method names.
it odd to me though that you have a panel context if the pages aren't running through Filament though. 🤷♂️
I think I don't really have a filament context, it's just returning the default panel when accessing the magic filament() helper.
could be
there are tons of getters but not for color 🙈
screw it, I'll make a config for that and call it on both. 😂
Thank you so much for the help! 🙏
might just have to register them in the service provider instead of on the panel directly
config works too.
yeah, I did that now. Thank you!
Just a FYI - I was running into the same issue. Added a
->getColors()
getter, should be available in the next update. https://github.com/filamentphp/filament/pull/9665