Allow components passed as slot prop to be used in the slot
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 54.4k
- Forks
- 9.2k
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 140
Description
What problem does this feature solve?
Example:
<template>
<SomeComponent v-slot="{ SpecializedComponent }">
<SpecializedComponent />
</SomeComponent>
</template>
At the moment, vue does not consider components passed as slot property on render. Instead it complains about "SpecializedComponent" being unknown.
Why is this useful:
- Allow to render parent-child relationships in an easy way:
This basically allows to wrap the inner content of a parent component with some custom styling or whatnot.
A similar concept is used in vue-router to display the current page (<router-view>)
<template>
<Table>
<template #td="{ Child }">
<td style="background: red">
<Child />
</td
</template>
</Table>
</template>
- Allow typed components that rely on props passed to the parent component
<template>
<Table :data="typedData" v-slot="{ Column }">
<Column prop="willErrorWithWrongKey" />
<Column v-slot="{ row }">
{{ row.typedProperties }}
</Column>
</Table>
</template>
Both cases are extremely useful for different reasons
What does the proposed API look like?
See above or look at this playground
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked Vue Playground reproduction and compare both examples: rendering a component supplied through slot props and preserving the typed component props. Done means slot-provided components render without an unknown-component warning and the demonstrated typed usages work as proposed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend, web-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100