Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Jakub003's avatar

Livewire page routes with {{$slot}} vs @yield / <x-slot>

Not sure if I am doing something wrong, or if there is only one way to make this work.

I created a route with a livewire component, and it works fine.

Route::get('/manage-projects/view-project/{projectUuid}/brief', ViewProjectBriefPage::class)->name('project.brief');

Using this documentation, https://laravel-livewire.com/docs/2.x/rendering-components I am seeing that livewire supports the blade stuff.

layouts.app.blade.php my layout file is something along the lines of this with slot names

...
{{$header}}

@if(isset($leftSidebar))
{{$leftSidebar}}
@endif

{{$body}}
...

Problem

In the livewire blade file, I created a layout like this, and it shows the content, but none of the functions or wire:models work.

<div>
    <x-slot name="header"> some stuff </x-slot>

    <x-slot name="leftSidebar"> some stuff </x-slot>

    <x-slot name="body"> 
        <button wire:click="createFunction()"> create button  </button>
    </x-slot>
</div>

Now the only way I got it working is to change the {{$body}} to be {{$slot}} in the app layout and got the functions in the body section working at least.

Question

If I use a livewire component as a web.php route do I only have access to one section like $slot? If that is the case I can work around this but would like to know if there is an alternative way to do this.

Any insight or tips on how this works would be much appreciated, or link to where I can learn more.

0 likes
2 replies
Jakub003's avatar
Jakub003
OP
Best Answer
Level 7

I got around this by just adding {{$slot}} to layout/app and than just having a template component for the differnt types of content layouts

// inside the laravel blade file
<x-template.centered-content>
    <div>
        Analytics Design
    </div>
</x-template.centered-content>
1 like

Please or to participate in this conversation.