Iman
Iman

Reputation: 571

How to set class and inline style to laravel blade component?

I have a component in Laravel Blade and want to set class or inline style to it without passing any data.

My simple code is:

<x-atom.form class="mt-5" :data="$fields->main_form"></x-atom.form>

mt-5 is not set to x.atom.form component

My component code is:

<section class="contact-form"></section>

Upvotes: 3

Views: 4133

Answers (1)

medilies
medilies

Reputation: 2218

resources\views\components\atom\form.blade.php

<section {{ $attributes->merge(['class' => 'contact-form']) }}>
   {{-- ... --}}
   {{-- ...  --}}
</section>

some_file.blade.php

<x-atom.form class="mt-5"></x-atom.form>

docs ref ref2

Upvotes: 6

Related Questions