New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Proposal] Render slots for components #1389

assertchris opened this Issue Nov 15, 2018 · 2 comments


None yet
2 participants

assertchris commented Nov 15, 2018


I love components, but there's something about them that makes it a little harder to compose them, than the client-side libraries we're used to. There's no way, currently, to use $slot as a function.

I can't, for instance, do this:

@component('components.list', ['items' => $items])
    <!-- treat slot as though it must be rendered once for each item -->
    {{ $item->label }}

...and then to create that component as:

@foreach($items as $item)
    {{ $slot($item) }}


If we add the following blade directive:

screenshot 2018-11-15 at 08 47 51

...and modify the ManagesComponents concern slightly:

screenshot 2018-11-15 at 08 48 26

...then we can make components like this:

screenshot 2018-11-15 at 08 49 15

...which can be used like this:

screenshot 2018-11-15 at 08 49 59

Whaddya think?

@assertchris assertchris changed the title from [Proposal] Render children for components to [Proposal] Render slots for components Nov 15, 2018


This comment has been minimized.

assertchris commented Nov 15, 2018

Inb4 someone points out you can already do this (slightly less appealing) thing:

screenshot 2018-11-15 at 08 56 30


This comment has been minimized.

tylernathanreed commented Dec 7, 2018

My work around for this involves declaring multiple slots, such as items.0.title, items.0.body, items.1.title, items.1.body. Making this work requires diciphering the $__data variable, which feels for like a hack than a feature.

Having some sort of array-based support for components would be great for accordions, lists, tab panels, etc.

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