Closed
Description
Describe the problem
In React, if you have a <Button>
component, you can spread its children
into a <button>
and it works fine.
function Button({ foo, ...props }) {
return <button {...props} />;
}
In Svelte, we have to do this:
<script>
let { children } = $props();
</script>
<button>
{#if children}
{@render children()}
{/if}
</button>
It's quite boilerplate-y.
Describe the proposed solution
Allow passing children
to HTML elements.
<script>
let { children } = $props();
</script>
<button {children} />
Alternatives considered
Just keep the current syntax, which is a tad bit boilerplate-y, but not a huge deal.
Importance
nice to have