Dynamic class on laravel

as im in process of learning laravel, i was wondering if there is any way to pass dynamic class in component…

folder-> view->components->common.blade.php

<div class="py-3 d-flex justify-content-center $dynamic">
        ---content goes here----
</div>

welcome.blade.php

so i want pass class to $dynamic like:bg-red for background-color, 
bg-image for background-image, bg-overlay for overlay-color.
<x-common>

</x-common>

i want pass some class on $dyanmic for use css for background-color,bg-image, padding etc according to need of design/ template

Hello synerdb,

Yes you can pass attributes to your components and with them merge them in. Take a look at the following link…

There you will see that in their custom component <x-alert> that they are passing along a class that is then merged with some default classes you choose to have in the component. They show an example where they pass the class mb-4 and it is merged with alert classes to form the full set of classes in the rendered component.

I hope this is what you were looking to do. :slight_smile:

1 Like

absolutely what i was looking for. appreciate for your guidance…

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.