I’ve been around the Laravel game for quite some time now, and sometimes it’s kind of hard to keep up with all the awesome new features released in this framework. I finally got around to digging into Blade View Components, which allow you to create reusable custom HTML tags. For instance, say that we had a common card element inside our application that looks like this:

<div class="card">

Now, instead of duplicating this code whenever we wanted to reuse it, we could create a blade component like so:

php artisan make:component Card

When you run the command, it will create an empty view component located at resources/views/components/card.blade.php. If we put our HTML into that file and want to reference our card element inside a view, we can now use the following HTML tag:


Pretty cool, right?

#laravel #php #html #developer

The Benefits of Blade View Components
3.00 GEEK