[Feature Request] Using VSelect v-slot:selection-display to override the entire selection output
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 41k
- Forks
- 7.1k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 11
Description
Problem to solve
The v-slot:selection slot in VSelect is currently limited to customizing individual selected items. If we need to change how to display selection for the entire state, it's currently possible only using a workaround.
For instance: showing a single label when all items are selected. If we were to implement this feature in our current v-select:selection slot, we'd have to resort to:
<script setup>
import { ref, computed } from 'vue';
const allItems = ['one', 'two'];
const itemsSelected = ref(['one', 'two']);
const allItemsSelected = computed(() => itemsSelected.value.length === allItems.length);
</script>
<template>
<VSelect v-model="itemsSelected">
<template #selection="{ item, index }">
{{
index > 1 && allItemsSelected
? ''
: index === 0
? allItemsSelected
? 'All items selected'
: item
: ''
}}
</template>
</VSelect>
</template>
Proposed solution
Enhance VSelect with a slot or prop for overriding the entire selection template. This would allow to easily define a custom template using v-slot:selection-display and use this to override the entire selection display, providing access to the full itemsSelected array.
Example:
<VSelect v-model="itemsSelected">
<template #selection-display="{ itemsSelected }">
{{ itemsSelected.length === allItems.length ? 'All items selected' : itemsSelected.join(', ') }}
</template>
</VSelect>
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 at the VSelect component and inspect how its existing selection slot renders selected items. Compare that behavior with the proposed selection-display API and identify the relevant component tests or examples. Done means the entire selection output can be customized while preserving the existing selection behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100