Skip to content

Instantly share code, notes, and snippets.

@jasonlbeggs
Created March 6, 2021 00:20
Show Gist options
  • Save jasonlbeggs/2cb11885809f52c2d15bad46dd2c66f5 to your computer and use it in GitHub Desktop.
Save jasonlbeggs/2cb11885809f52c2d15bad46dd2c66f5 to your computer and use it in GitHub Desktop.

Blade Scoped Slots

Blade Components have the concept of "Scoped Slots" similar to Vue.js. This allows you to access public properties and methods on the component inside slots. Super handy in certain cases.

<x-alert>
    <x-slot name="title">
        {{ $component->formatAlert('Server Error') }}
    </x-slot>

    <strong>Whoops!</strong> Something went wrong!
</x-alert>

Read more about scoped slots in the Blade documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment