Layouts & Components in PHP

From the Laravel cheat sheet · Blade Templates · verified Jul 2026

Layouts & Components

Blade layouts, components, and slots

php
{{-- Layout file: layouts/app.blade.php --}}
<!DOCTYPE html>
<html>
<head>
    <title>@yield('title', 'Default Title')</title>
</head>
<body>
    @section('sidebar')
        Default sidebar
    @show

    <div class="container">
        @yield('content')
    </div>
</body>
</html>

{{-- Child view --}}
@extends('layouts.app')

@section('title', 'Page Title')

@section('content')
    <p>Page content</p>
@endsection
💡 Use @parent to include parent section content
⚡ Components promote reusability and clean templates
📌 Anonymous components are simpler for basic needs
🔥 x-slot allows multiple named slots in components

Continue with Laravel

Save the full cheat sheet or work through every related task.

More PHP tasks

Back to the full Laravel cheat sheet