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

krie9er's avatar

Where is the $slot of a component defined?

Hey I tried digging in the rabidhole, I was chattibg with a fried of mine about the awesome compents of Laravel and it's blade engine. He asked, where is the $slot defined. I looked into the components class and in the doc. But I can't determine where the $slot is defined. I am sure, I have just missed the point, can you help me out here? Kind regards

0 likes
5 replies
Snapey's avatar

If you define a component, and use it like this;

<x-button>
	Press to explode kittens
</x-button>

then 'Press to ...' becomes the $slot variable, then in the component can be used as {{ $slot }}

krie9er's avatar

Thabks for thw replies, I am just wondering, why the $slot ist available for the blade engine. In the ManagesComponents is 'only' a function, which is called slot() but no public var. Maybe it is a basic question, but, if the $slot = ManagesComponents::slot() how is this been made?

I just want to understand the mechanics behind it xD

newbie360's avatar

the {{ $slot }} just give a way without assign a variable to render the content

here below two component are the same

<x-button test="something" />

is same as

<x-button>
	<x-slot name="test">
		something
	</x-slot>
</x-button>

so if $test content any html or logic code, the second component is more readable

krie9er's avatar

Yeah I know that @newbie360 I just want to understand, how $slot and the name slots are made accessible in the component. When you look into the components class, then you find there the $attributes var defined, but I miss the definition of slot and transistion of hte named x-slot into a available var.

Please or to participate in this conversation.