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

thi's avatar
Level 1

<x-slot> usage in Blade not working

Hi :)

  • I try to use x-slot as defined in doc : docs/8.x/blade#slots
  • The browser gives me this error : Undefined variable $trigger (View: ema.blade.php)

ema.blade.php :

@props(['trigger'])
  <div x-data="{ show: false }" @click.away="show = false" class="relative">
    {{--Trigger--}}
    <div @click="show = !show">
      {{ $trigger }}
    </div>
    {{--Links--}}
    <div x-show="show" style="display: none">
      {{ $slot }}
    </div>
  </div>

and in my plant.blade.php :

<x-ema>
          <x-slot name="trigger">
            <button class="text-xs font-bold uppercase">Plant</button>
          </x-slot>

		<div>Details of plant</div>
</x-ema>

Thanks :)

0 likes
8 replies
thi's avatar
Level 1

@Nakov Thank u for your response. I try to do the same as here : laracasts.com/series/laravel-8-from-scratch/episodes/35 using x-slot

thi's avatar
Level 1

I don't know why, but when i use the word "trigger" as a name of x-slot that not working. I changed the "trigger" with "title" and now it's working. thanks anyway.

Snapey's avatar

@thi

named slots are in the format <x-slot:trigger> and not name=

kokoshneta's avatar

@Snapey Do both not still work? When you install Breeze, for example, it still uses the name= format in the components used for the various authentication pages, and that seems to work all right.

1 like
anchan42's avatar

work much better with code formatting tools. It should be in the documentation. I don't think "trigger" prop though. Slot and prop are two different thing.

Please or to participate in this conversation.