DeveloperBreeze

Blade Components Development Tutorials, Guides & Insights

Unlock 3+ expert-curated blade components tutorials, real-world code snippets, and modern dev strategies. From fundamentals to advanced topics, boost your blade components skills on DeveloperBreeze.

Creating Custom Blade Components and Directives

Tutorial November 16, 2024
php

   namespace App\View\Components;

   use Illuminate\View\Component;

   class Button extends Component
   {
       public $type;
       public $label;

       public function __construct($type = 'primary', $label = 'Submit')
       {
           $this->type = $type;
           $this->label = $label;
       }

       public function render()
       {
           return view('components.button');
       }
   }

In resources/views/components/button.blade.php:

Understanding Traditional Layouts vs. Component-Based Layouts in Laravel

Tutorial August 22, 2024
php

resources/views/layouts/master.blade.php:

  <!DOCTYPE html>
  <html lang="en">
  <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>@yield('title', 'My Laravel App')</title>
      <link rel="stylesheet" href="{{ asset('css/app.css') }}">
  </head>
  <body>
      <header>
          @include('partials.header')
      </header>

      <main>
          @yield('content')
      </main>

      <footer>
          @include('partials.footer')
      </footer>

      <script src="{{ asset('js/app.js') }}"></script>
  </body>
  </html>

Understanding Laravel Layouts and Their Usage

Tutorial August 22, 2024
javascript css php

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>@yield('title', 'My Laravel App')</title>
    <link rel="stylesheet" href="{{ asset('css/app.css') }}">
</head>
<body>
    <header>
        <nav>
            <ul>
                <li><a href="{{ url('/') }}">Home</a></li>
                <li><a href="{{ url('/about') }}">About</a></li>
                <li><a href="{{ url('/contact') }}">Contact</a></li>
            </ul>
        </nav>
    </header>

    <main>
        @yield('content')
    </main>

    <footer>
        <p>© 2024 My Laravel App. All rights reserved.</p>
    </footer>

    <script src="{{ asset('js/app.js') }}"></script>
</body>
</html>

Explanation: