[labs/react] Support adding children to multiple slots
See original GitHub issueDescription
Currently, the react wrapper supports adding children to a default slot.
In order to support multiple slots from react -> lit wrapper, the react dev might have to wrap their components in an html element as an attribute.
() => (
<div slot="slotA">
<MyReactComponent />
</div>
<div slot="slotB">
<MyReactComponent />
</div>
</div slot="slotC">
<MyReactComponent />
</div>
)
It’d be nice to support multiple slots in a shallow manner with react
export const MyElementComponent = createComponent(
React,
'my-element',
MyElement,
{
onChange: 'input',
},
{
propName: 'slot_name',
icons: 'icons',
suffix: 'suffix',
}
);
However, rendering might be an issue between react and lit. The major hurdle is setting the slot
attribute on an html element rendered in react.
Acceptance criteria
-
Decide if this is a feature the labs react wrapper should support
-
If we go forward, we need to agree on how to extend our API
-
Provably use slotted react components in multiple web component slots
Issue Analytics
- State:
- Created a year ago
- Comments:10 (7 by maintainers)
Top Results From Across the Web
Pass Multiple Children to a React Component with Slots
This component needs to be able to accept multiple children and place them in the layout as it sees fit – not right...
Read more >First Lit & Friends Community Call! · Discussion #2986 - GitHub
Work in progres for this in [@labs/react] support multiple children with multiple slots #2985; We could also consider adding slotted content constraint ...
Read more >Lit for React Developers - Google Codelabs
Lit is a simple library for building fast, lightweight web components that work in any framework, or with no framework at all. With...
Read more >Component composition / Slots • Svelte Tutorial
Before a component can accept children, though, it needs to know where to put them. We do this with the <slot> element. Put...
Read more >Building Interoperable Web Components That Work | CSS-Tricks
Those of us who've been web developers more than a few years have probably written code using more than one JavaScript framework.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
oh nice! display: contents will work with primitives, document fragments </> etc and is just better. I use a custom implementation of createReactComponent and I will try contents as I dont need to IE11.
Setting the style to
display: contents
will keep the wrapper from interfering with styles.