Blade components props

1// button.blade.php
2@props(['rounded' => false])
3 
4<button {{ $attributes->class([
5 'bg-red-100 text-red-800',
6 'rounded' => $rounded
7 ]) }}>
8 {{ $slot }}
9</button>
10 
11// view.blade.php
12// Non-rounded:
13<x-button>Submit</x-button>
14 
15// Rounded:
16<x-button rounded>Submit</x-button>

Tip given by @godismyjudge95

Like our articles?

Become a Premium Member for $129/year or $29/month
What else you will get:
  • 22 courses (477 lessons, total 38 h 20 min)
  • 2 long-form tutorials (one new every week)
  • access to project repositories
  • access to private Discord