Mahmoud Al-HabashOpen to new projects
  • WorkWork
  • ServicesServices
  • LabLab
  • WritingWriting
  • ContactContact
Amman--:--عربي
Writing/Laravel

Livewire Layout Components Pattern

Create reusable layout components for Livewire pages.

16 January 20261 min readLaravelاقرأ بالعربية

On this page

  1. Define Layout
  2. Layout File
  3. With Title
  4. Dynamic Title

Layout components:

Define Layout

#[Layout('layouts.app')]
class Dashboard extends Component
{
    public function render()
    {
        return view('livewire.dashboard');
    }
}

Layout File

blade
<!-- layouts/app.blade.php -->
<html>
<body>
    <nav>...</nav>
    {{ $slot }}
    <footer>...</footer>
</body>
</html>

With Title

#[Layout('layouts.app')]
#[Title('Dashboard')]
class Dashboard extends Component {}

Dynamic Title

php
public function render()
{
    return view('livewire.post')
        ->title($this->post->title);
}
All articles

Keep reading

  • Laravel Action Classes Pattern16 January 20261 min read
  • Laravel Action Classes: Single Responsibility16 January 20261 min read
  • Laravel API Rate Limiting16 January 20261 min read