A slot can be declared with the self-closing <slot>
tag.
Slots can have a name.
Default slot contents can be passed as children.
Named slot contents can be passed by setting a slot
attribute on an HTML element.
The contents of a Svelte component can be passed through slots. Svelte supports default slots, named slots, and slots that pass data back to the slotted content (also known as scoped slots).
In this example, we'll wrap our todo list in a layout component.
A slot can be declared with the self-closing <slot>
tag.
Slots can have a name.
Default slot contents can be passed as children.
Named slot contents can be passed by setting a slot
attribute on an HTML element.
You can check whether a component has provided named slot contents through $$slots
.
With slot props, a component can pass data to the slot content.
Data can be passed to slot
like it's a component.
Data can be bound to a variable with a let:<name>
attribute.
Further reading on this topic.