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

stevefink's avatar

<x-slot> usage in Blade Component Cookbook

Hi :)

Should be a trivial question. I noticed in the Blade Component Cookbook series, namely in the modal episode located here: https://laracasts.com/series/blade-component-cookbook/episodes/5, a component named <x-slot> was used.

Is this a built-in Blade component? I don't see to recall Jeff building a slot.blade.php anywhere. I also noted the usage of $trigger in the actual component definition file. Where is this coming from?

Thanks :)

0 likes
2 replies
jbloomstrom's avatar
Level 50

Slots pass markup into a component. x-slot allows you to define named slots.

You may define the content of the named slot using the x-slot tag. Any content not within a x-slot tag will be passed to the component in the $slot variable:

https://laravel.com/docs/7.x/blade#slots

Victor Paredes's avatar

I'm newish to everything, but I also want to note that there is an alternative way to accomplish the same thing: @slot.

For example, you can use the following to pass a "title" variable from your view/component to the insertion point:

@slot('title')
    Page title
@endslot

After reading through the documentation over and over and getting kind of frustrated (my own learning journey), I did a quick writeup on it: https://victorpared.es/articles/laravel-blade-101

1 like

Please or to participate in this conversation.