-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Description
Describe the problem
It is not uncommon that a component is filled up using specific subcomponents, consider the following:
<Modal>
<ModalHeader>...</ModalHeader>
<ModalContent>...</ModalContent>
<ModalFooter>...</ModalFooter>
</Modal>in order to ensure everything is on it's place, the Modal component would use slots:
<div class="modal">
<div class="modal_header"><slot name="header" /></div>
<div class="modal_content"><slot name="content" /></div>
<div class="modal_footer"><slot name="footer" /></div>
</div>This would in turn mean that the original code becomes
<Modal>
<ModalHeader slot="header">...</ModalHeader>
<ModalContent slot="content">...</ModalContent>
<ModalFooter slot="footer">...</ModalFooter>
</Modal>which is not very developer friendly for the consumer of the component.
It would be nice to have a way to say that a specific component should always be rendered into a specific slot.
Describe the proposed solution
one possibility would be to expose this as a prop from the component, I would expect in the "context module" since this is a property common to all instances.
<script context="module">
export const slot = "header";
</script>a better (subjectively) might be to allow it to be set in svelte:options
<svelte:options slot="header" />Things to consider here is that maybe this should be possible to override ? Like a "prefered slot" option.
Alternatives considered
Do nothing.
Importance
nice to have