When faced with a challenge like this, my approach involves examining the DOM closely and drawing comparisons between the standard prepend element and the v-slot prepend element. One key aspect to note is that using v-slot replaces everything, so it's essential to identify any variations in HTML structure and/or styling when switching between using v-slot and not.
Troubleshooting
The typical prepend element typically appears as follows:
<div class="v-list-item__prepend">
<i class="mdi-email-fast mdi v-icon notranslate v-theme--light v-icon--size-default" aria-hidden="true" density="default"></i>
<div class="v-list-item__spacer"></div>
</div>
On the other hand, the prepend v-slot has a different structure:
<div class="v-list-item__prepend">
<div class="v-progress-circular v-progress-circular--visible v-theme--light text-deep-orange-lighten-2" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="30" style="width: 25px; height: 25px;">
<svg>...</svg>
</div>
<div class="v-list-item__spacer"></div>
</div>
By transferring the classes from the <i>
element to the <v-progress-circular>
, the spacing issue can be resolved. Nevertheless, this adjustment introduces additional styles. To tackle this, one can analyze the CSS or gradually remove classes until pinpointing that only the "v-icon" class is necessary for the v-progress-circular component.
This specific class sets width: 32px
on the v-list-item__spacer
div. Inspecting the v-list-item__spacer
within the custom v-slot reveals that its width remains at 0 until the "v-icon" class is added. However, without wanting all associated styles, you can exclude the class and directly assign the 32px.
To implement this change, include a custom class, such as "customPrepend," in your single v-list-item to establish a selector for required CSS adjustments.
Resolution
<v-list-item class="customPrepend">
<template #prepend>
<v-progress-circular
model-value="30"
size="25"
color="deep-orange-lighten-2"
></v-progress-circular>
</template>
<template #title> Progress </template>
</v-list-item>
<style scoped>
.customPrepend :deep(.v-list-item__prepend .v-list-item__spacer) {
width: 32px;
}
</style>
Check out the Vuetify Playground example