Laravel 7 Blade X features give you the ability to make a class-less component.

Previously Laravel made use of @component syntax for blade components which is still intact and not removed from Laravel7.
In Laravel 7, Taylor has introduced syntax like vueJS, its called Blade X. We can pass props, custom props and so on.

Use Case

Let’s say we’ve a layout template, which represents a top-level component & rest of the view components extending this layout template.

We can do something like:

<x-layout title='devpeel'>
  <x-slot name="sidemenu">
     menu goes here

Clean isn’t it?

Now lets create a new component.

php artisan make:component Notification

It will create a notification blade partial & second in App\View\Components, it creates a view model for you. Any public properties that we define here will instantly be available in the corresponding partial.

You may also Like