Bird
0
0

You want to create a reusable modal component with a named slot title and default slot for body content. How should you define the component template to display both correctly?

hard📝 component behavior Q8 of 15
Laravel - Views and Blade Templates
You want to create a reusable modal component with a named slot title and default slot for body content. How should you define the component template to display both correctly?
A
B
C
D
Step-by-Step Solution
Solution:
  1. Step 1: Use correct variable names for slots

    Named slot "title" is accessed as $title, default slot as $slot.
  2. Step 2: Arrange HTML to show title then body

    Title should appear in <h2>, body in a <div> below.
  3. Final Answer:

    <div class="modal"> <h2>{{ $title }}</h2> <div>{{ $slot }}</div> </div> -> Option D
  4. Quick Check:

    Named slot = $title, default slot = $slot [OK]
Quick Trick: Use $title for named slot, $slot for default content [OK]
Common Mistakes:
  • Using wrong variable names
  • Swapping slot variables
  • Ignoring slot naming conventions

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Laravel Quizzes