Bird
0
0

What will be rendered by this Blade component usage?

medium📝 component behavior Q5 of 15
Laravel - Views and Blade Templates
What will be rendered by this Blade component usage?
<x-card>
  <x-slot name="header">Title</x-slot>
  Content here
</x-card>

Assuming the card component template is:
<div class="card">
  <header>{{ $header }}</header>
  <main>{{ $slot }}</main>
</div>
A
Title
Content here
B
Content here
Title
C
Content here
DAn error will occur because $header is undefined
Step-by-Step Solution
Solution:
  1. Step 1: Map named slot to $header variable

    The named slot "header" content "Title" is assigned to $header in the component.
  2. Step 2: Map default slot to $slot variable

    The default slot content "Content here" is assigned to $slot.
  3. Final Answer:

    <div class="card"><header>Title</header><main>Content here</main></div> -> Option A
  4. Quick Check:

    Named slot = $header, default slot = $slot [OK]
Quick Trick: Named slot content = $name, default slot = $slot [OK]
Common Mistakes:
  • Swapping header and default slot
  • Assuming $header is empty
  • Expecting error on missing variables

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Laravel Quizzes