#Dealing with css in components
3 messages · Page 1 of 1 (latest)
Blade doesn't really support scoped CSS like you would find in a js/react-style project.
It's subjective but I would highly recommend using a utility-based css package like Tailwind. While it might be a challenging transition at first, I think you'll find it's a great way to build blade components. For inspiration, I would check out some of the default components found in Laravel's starter kits like Breeze https://laravel.com/docs/11.x/starter-kits#laravel-breeze
That said, if you want to keep your manually-created css coupled with your blade files I can think of a couple ways you might go about it:
Assuming you have a main layout template you could use stacks https://laravel.com/docs/11.x/blade#stacks or slots to inject component-specific css. I'm not sure this is a great idea but could work. Maybe others could chime in.
Also, you can use React with Laravel. https://laravel.com/docs/11.x/frontend#using-vue-react
hmm well i could probably use inline css and herodoc