Vuetify's v-list-item no longer has spacing issues when using the v-slot:prepend feature

Currently, I am in the process of designing a side navigation using v-navigation-drawer. While most of my items utilize an icon, I also want to create some custom behaviors. Unfortunately, the title in v-slot:title does not align with the title in the v-list-item that uses prepend-icon. How can I achieve this desired behavior?

    <v-navigation-drawer
        location="left"
        width="250"
        permanent
    >
      <v-list>
        <v-list-item prepend-icon="mdi-account" title="Profile" to="/profile"></v-list-item>
        <v-list-item prepend-icon="mdi-email-fast" title="Feedback" to="/feedback"></v-list-item>

        <v-list-item>
          <template v-slot:prepend>
                <v-progress-circular
                    model-value="30"
                    size="25"
                    color="deep-orange-lighten-2"
                ></v-progress-circular>
          </template>

          <template v-slot:title>
                Progress
          </template>
        </v-list-item>
      </v-list>
    </v-navigation-drawer>

Answer №1

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

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Loop through a series of objects using a for loop

I need help with looping through a set of objects using a for loop, but I'm encountering an issue because they do not have the same name. <div id="components-demo"> <div>Travel Information</div> <ul> <li ...

Clicking on the checkbox will trigger the corresponding table column to disappear

Upon clicking the filter icon in the top right corner, a menu will open. Within that menu, there are table header values with checkboxes. When a checkbox for a specific value is selected, the corresponding table column should be hidden. I have already impl ...

What is causing `foo()` to function in this specific scenario?

Check out this code snippet: https://jsfiddle.net/5k10h27j/ I'm puzzled by why foo() is being called as an argument to a non-existent function. function foo(){ alert('huh??'); } jQuery('#container').on('change', ...

jquery events such as onSubmit, onComplete, etc. are commonly used

It's interesting to observe that many tools in jQuery, especially those involving ajax, contain hooks like onSubmit, onComplete, and more. Is there a specific term for this practice and the standards associated with it? Does this practice belong sol ...

Guide on embedding PHP/MYSQL array into an independent JavaScript document

I'm looking for guidance on how to insert an array from a PHP MySQL page into a separate JavaScript file. Can someone please help me with indicating where to include the PHP URL and provide the correct format for the PHP array code in order to achieve ...

I am attempting to retrieve the information entered into the textbox, search for it within my database, and display the results beneath the textbox for reference

<!----- fetchCedulaData.php This script retrieves data from the database and performs a search to return results ---------------------------- - --> <?php require("connection.php"); $cedula=$_REQUEST["cedula"]; //$cedula="0922615646"; echo $cedu ...

Set a value for the hidden field on the page using client-side scripting

When working with an ASP.net application, I often use Page.ClientScript.RegisterHiddenField("hf_Name", value). However, I am curious about how to override or set a new value for the same Hidden Field 'hf_Name' in the code behind. Can you provide ...

Experiencing the issue with the $.getJSON function bug

Is there a way to ensure that my code processes the $.getJSON function fully? I am encountering an issue where only the first alert, 'inside1', is triggered when running the site. The second alert, 'inside x2', never gets processed. Any ...

Ways to forward a parameter to a different web address?

Is there a way to properly redirect a parameter such as http://example.com/?link=https://google.com to its destination at ? ...

Preventing Javascript Pop Up from automatically jumping to the top of the page

Upon clicking a button (refer to image below and take note of the scroll bar position), a div pop up is triggered through Javascript. View image: https://docs.google.com/file/d/0B1O3Ee_1Z5cRTko0anExazBBQkU/preview However, when the button is clicked, the ...

Display a message on the webpage itself, not in a pop-up, when the value exceeds 1 using JavaScript

I need help with a condition involving a variable called "truecount." If this value is less than one, I would like to display an error message on the screen instead of an alert popup. Could someone assist me with this? I am new to this and don't have ...

JavaScript fails to focus on dynamically inserted input fields

Within my HTML template, there is an input element that I am loading via an Ajax call and inserting into existing HTML using jQuery's $(selector).html(response). This input element is part of a pop-up box that loads from the template. I want to set f ...

Accessing public static files in Express by using the routes folder

I'm currently facing an issue with accessing a static file named 'home.html' located in the public directory of my app's architecture: public home.html routes index.js views myapp.js In myapp.js: var express = require('ex ...

Focus automatically on an input component when the value in the Vuex store is updated in Vue

Here's the code snippet from my component: //template <v-select ref='ItemSearchSelect' :options="options"></v-select> ... //script created: function () { this.$store.subscribe((setFocusSearch, state) => { ...

Guide on inserting a new column into an array of objects in Vue

Below is the fetch method I have defined to retrieve recordings from the database. However, I need assistance in adding a new column to each record specifically for frontend purposes. Can someone help me with this problem? <script> export default { ...

JavaScript - Attempting to retrieve data using AJAX

Struggling with extracting data from an AJAX call using jQuery while implementing RequireJS for better maintainability and modularity in my JavaScript. Still new to RequireJS so not entirely sure if I'm on the right track. Just aiming to keep my JS mo ...

Using jQuery to iterate through elements of a PHP array

I've got a PHP array that outputs like this: Array ( [0] => Array ( [title] => Much title [end] => Such end [start] => Very start ) [1] => Array ( [title] ...

What significance does the slash hold in a package name when using require for an npm package?

When we "require" non-local NodeJS modules, what does the slash in the module name signify? For instance: from the GitHub page of the ShellJS npm module (link: https://github.com/shelljs/shelljs#javascript) require('shelljs/global'); requir ...

How to create a Bootstrap panel that collapses on mobile devices and expands on desktop screens?

Is there a simple way to remove the "in" class from the div with id "panel-login" when the screen size is less than 1199px (Bootstrap's xs, sm, and md modes)? I believe JavaScript or JQuery could be used for this, but I'm not very proficient in e ...

Can the chrome console be used to showcase the contents of objects?

When I have a line of code, and I try to output it to the console, I only see [object Object] instead of the actual object types. console.log(`%c ${args[args.length-1]} ${performance['now'](true, args[args.length-1])} [(${args.slice(0, args.leng ...