I’m new at Laravel and recently came across this problem. I’d like to override the background of my Laravel 11 component, but instead I’m just adding an extra class. How can I solve this? For example:
<code><div {{$attributes->merge(['class' => 'bg-blue-100'])}}>
{{$slot}}
</div>
<x-card class="bg-black">
...
</x-card>
</code>
<code><div {{$attributes->merge(['class' => 'bg-blue-100'])}}>
{{$slot}}
</div>
<x-card class="bg-black">
...
</x-card>
</code>
<div {{$attributes->merge(['class' => 'bg-blue-100'])}}>
{{$slot}}
</div>
<x-card class="bg-black">
...
</x-card>
Instead of class=”bg-black” I end up with class=”bg-blue-100 bg-black”. Is there anyway around it other than exluding bg-blue-100, because I’d like to have a default background.
Thanks
New contributor
laravelStudent is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.