Laravel - Blade Templates - Slots
You will often need to pass additional content to your component via "slots". Component slots are rendered by echoing the $slot
variable. To explore this concept, let's imagine that an alert
component has the following markup:
{{ $slot }}
We may pass content to the slot
by injecting content into the component:
Whoops! Something went wrong!
Sometimes a component may need to render multiple different slots in different locations within the component. Let's modify our alert component to allow for the injection of a "title" slot:
{{ $title }}
{{ $slot }}
You may define the content of the named slot using the x-slot
tag. Any content not within an explicit x-slot
tag will be passed to the component in the $slot
variable:
Server Error
Whoops! Something went wrong!