Tips for arranging a checkbox and an icon in vuetify

I'm looking for a layout with checkboxes and remove icons:

+ |‾‾‾‾‾‾|
- |______|

Here's my current attempt:

<!DOCTYPE html>
<html>

<head>
  <link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900" rel="stylesheet">
  <link href="https://cdn.jsdelivr.net/npm/@mdi/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="8ceae3e2f8ccbfa2f4">[email protected]</a>/css/materialdesignicons.min.css" rel="stylesheet">
  <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="14626171607d726d54263a6c">[email protected]</a>/dist/vuetify.min.css" rel="stylesheet">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
</head>

<body>
  <div id="app">
    <v-app>
      <v-col cols="12" md="6" v-for="(choice, idx) in choices" :key="idx">
        <v-text-field v-model="choice.text" outlined clearable type="text">
          <template v-slot:prepend>
              <v-col>
                <v-checkbox v-model="choice.isCorrect" hide-details />
                <v-icon color="red" left>remove_circle</v-icon>
              </v-col>
            </template>
        </v-text-field>
      </v-col>
    </v-app>
  </div>

  <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c7b1b2a287f5e9bf">[email protected]</a>/dist/vue.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f6808393829f908fb6c4d88e">[email protected]</a>/dist/vuetify.js"></script>
  <script>
    new Vue({
      el: '#app',
      vuetify: new Vuetify(),
      data() {
        return {
          choices: [{
              text: "Foo",
              isCorrect: true
            },
            {
              text: "Bar",
              isCorrect: false
            }
          ]
        }
      }
    })
  </script>
</body>

</html>

Answer №1

In my opinion, it would be more effective to create a separate div specifically for this purpose rather than utilizing the prepend slot, which seems to have an unusual custom margin that doesn't quite fit the task at hand. I made some modifications to your code to achieve the desired effect - check it out here: https://codepen.io/CodingDeer/pen/LYPbPxr.

I've also included the snippet below, but it appears that the icon is not functioning properly in this context.

<!DOCTYPE html>
<html>

<head>
  <link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900" rel="stylesheet">
  <link href="https://cdn.jsdelivr.net/npm/@mdi/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1f7970716b5f2c3167">[email protected]</a>/css/materialdesignicons.min.css" rel="stylesheet">
  <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b0c6c5d5c4d9d6c9f0829ec8">[email protected]</a>/dist/vuetify.min.css" rel="stylesheet">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
</head>

<body>
    <div id="app">
<v-app>
  <v-col cols="12" md="6" v-for="(choice, idx) in choices" :key="idx">
    <v-row>
      <div>
        <div>
          <v-checkbox 
            class="ma-0"
            v-model="choice.isCorrect" 
            hide-details />
        </div>
        <v-icon color="red">remove_circle</v-icon>
      </div>
      <v-text-field v-model="choice.text" outlined clearable type="text">
      </v-text-field>
    </v-row>
  </v-col>
</v-app>
  </div>

  <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1e686b7b5e2c3066">[email protected]</a>/dist/vue.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e6909383928f809fa6d4c89e">[email protected]</a>/dist/vuetify.js"></script>
  <script>
    new Vue({
      el: '#app',
      vuetify: new Vuetify(),
      data() {
        return {
          choices: [{
              text: "Foo",
              isCorrect: true
            },
            {
              text: "Bar",
              isCorrect: false
            }
          ]
        }
      }
    })
  </script>
</body>

</html>

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

Creating a dynamic data table in Vuetify using Vue.js by making an API call

Could anyone provide me with an example of how to create a dynamic data table using Vuetify in Vue.js? I have checked the official documentation but couldn't find any examples. ...

Automatically insert a comma for type=number in VueJS

Is there a method available to automatically insert commas into an input type="number" field in vue js? I need this functionality to trigger the IME options in Microsoft and prevent users from inputting Japanese characters. <ui-textbox label="initial" ...

The Materialize CSS tabs are aligning vertically below each other, but functioning correctly upon refreshing the page

When using materialize css tabs, all the divs load one below the other on the initial page load. If I refresh the page, it starts behaving properly. <div class="row"> <div class="col s12"> <ul class="tabs"> <li class="tab col s ...

Transforming color images into black and white using JavaScript

     I have implemented this code to convert colored images to grayscale. function applyGrayscaleEffect() {         var imageData = contextSrc.getImageData(0, 0, width, height);         var data = imageData.data;         var p1 = 0.99;   ...

How can you eliminate a line from the HTML input mask in Gravity Forms?

With Gravity Forms, I am utilizing the "input masks" feature to prompt users to enter data in a specific format. However, it seems to be creating an unwanted line within the input field itself as shown in the image below: https://i.stack.imgur.com/8gQ3K.j ...

What is preventing me from using JavaScript to generate labels?

My current project involves creating dynamic input fields to filter products by color. I initially attempted static checkbox inputs for this purpose, which worked fine. Now, I want to achieve the same functionality but dynamically through JavaScript. Inste ...

An innovative tool for discovering how different colors will complement each other

Design may not be my strong suit, but there are times when I need to add a border line or a shade of gray to a background color. Is there a tool available where I can specify background color: #343434 color: #asdfgh and visually see how it will look wit ...

What is the method to set a default sorting for a v-data-table?

I'm having trouble getting the default sorting to function properly. The custom-sort argument in the documentation is described as a "Function used to sort items", but the specifics are unclear. I'm unsure if it is called for an initial sort and ...

The error message "Quasar VUE_PROD_HYDRATION_MISMATCH_DETAILS has not been declared" is

Currently using quasar in conjunction with Vite. Upon installation of Quasar via yarn create quasar, a warning message appears in the console: __VUE_PROD_HYDRATION_MISMATCH_DETAILS__ is not explicitly defined. You are running the esm-bundler build of Vue, ...

Is there a way for me to place an image in the background with CSS? When I try to do so, the upper curve looks great, but the bottom of the image appears flat

.bg-pink{ background-image:url(https://i.sstatic.net/eF8tF.png); background-size: cover; margin-bottom: 44px; background-position: top; } <body> <!-- Top content --> <div class="top ...

Utilize Vue to have images expand individually upon clicking

Looking to create an image modal using HTML, CSS, and Vue. As a novice in this area, I am facing an issue where clicking on one image enlarges all of them, instead of just the selected one. This is happening because I am looping through an array for the im ...

The smooth transition of my collapsible item is compromised when closing, causing the bottom border to abruptly jump to the top

Recently, I implemented a collapsible feature using React and it's functioning well. However, one issue I encountered is that when the collapsible div closes, it doesn't smoothly collapse with the border bottom moving up as smoothly as it opens. ...

What is the best way to resize a background image to perfectly fit the visible screen on a mobile device?

When accessing the website on a mobile device, the background image adjusts based on the amount of content on the page. It expands when there is more content and shrinks when there is less. For instance, opening the navigation panel on a mobile device caus ...

Personalizing Material-UI Components using Styled-Components

My attempt to modify the props of a material-ui Grid component using styled-components was not successful. I initially tried: const NavGrid = styled(Grid)` direction: 'row'; ` Unfortunately, this approach did not yield the desired result. T ...

Issue with text decoration in Html, Css, and Bootstrap

this image shows the issue Hi there, I'm facing an issue with my project involving bootstrap. Whenever I include bootstrap in my project using a link, all "a" tags end up with text decoration. How can I fix this problem? ...

Sequential enumeration of elements visible in Vue

I have a survey form that contains various questions. Some of these questions are conditional and only appear based on certain criteria. I want to assign sequential numbers to each visible question, regardless of how many hidden questions exist in the te ...

Creating a resizable textarea component in JavaScript/React that adjusts its height dynamically but stops growing when

I am looking to create a textarea that initially displays as a single line but can expand up to 4 lines, and then start scrolling once the maximum height is reached. I have a solution in progress where it grows up to the limit, but does not shrink back dow ...

Error: TweenLite has not been recognized

/justincavery/pen/mPJadb - this is a link to CodePen After copying the code from CodePen and running it, I encountered an error: "Uncaught ReferenceError: TweenLite is not defined". The image only draws once and there is no animation unless I press "F5 ...

I am attempting to get a jquery plugin to function properly on my Windows 7 Internet Explorer IE7 browser. The plugin in question can be found at http://jvectormap.owl-hollow

I'm encountering some strange issues with my Internet Explorer IE7 browser on Windows 7. The jquery plugin I am attempting to use can be found at . Unfortunately, this plugin is not functioning properly on Internet Explorer IE7 on Windows 7, but it ru ...

Can @media screen rules be included in a loop for optimization?

Having @media screen rules in my CSS file that appear as follows: @media screen and (min-width: calc((180px + 40px) * 1 - 40px)) { #main-form { width: calc((180px + 40px) * 1 - 40px); } #main-projects { width: calc((180px + 40px) * 1); } } ...