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

codeXX's avatar
Level 1

Wire & Alpine are not accessible in named slot of layout file

I have just noticed that $wire & alpine are not accessible in named slots. Doe anyone have any idea what could be the reason?


// layout.blade.php

...
<div>
	{{ $header }}
</div>

{{ $slot }}

...

// page.blade.php
<?php
use Livewire\Attributes\Layout;
use Livewire\Volt\Component;

new #[Layout('layouts.layout')] class extends Component {
		...
};

?>

@script

	<script>

		// some page script...

	</script>

@endscript

<div>

<x-slot:header>
	<!-- works-->
	<x-primary-button onclick="console.log('hello')">Save</x-primary-button>

		<!-- doesn't work-->
	<x-primary-button @click="console.log('hello')">Save</x-primary-button>

	<!-- Error-->
	<x-primary-button onclick="console.log($wire)">Save</x-primary-button>

</x-slot:header>

</div>
0 likes
0 replies

Please or to participate in this conversation.