devnotes.

Layouts and Components

Rather than repeating <html>, <head>, and navigation markup on every page, Blade offers two ways to reuse layout: template inheritance and components.

Template inheritance:

{{-- resources/views/layouts/app.blade.php --}}
<html>
<body>
    @include('partials.nav')
    <main>@yield('content')</main>
</body>
</html>

{{-- resources/views/posts/index.blade.php --}}
@extends('layouts.app')
@section('content')
    <h1>All Posts</h1>
@endsection

Blade components (the modern, more powerful approach) are reusable, self-contained pieces of UI, generated with:

php artisan make:component Alert

This creates app/View/Components/Alert.php and resources/views/components/alert.blade.php. Use it anywhere with <x-alert type="error">Something went wrong.</x-alert>, and access the slot content and passed attributes inside the component view via {{ $slot }} and $type.

Anonymous components skip the PHP class entirely — just drop a Blade file in resources/views/components/ and reference it the same way. Components can also accept typed props, have default values, and be nested, making them ideal for building a consistent design system across a large application.

Laravel Blade Layouts & Components Guide | DevNotes