Reputation: 6238
I want something like this (+ is checkbox, - is remove icon):
+ |‾‾‾‾‾‾|
- |______|
Here is what I've tried so far:
<!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/[email protected]/css/materialdesignicons.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/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/[email protected]/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/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>
Upvotes: 0
Views: 2745
Reputation: 1677
Honestly it seems better to just create a separate div for this rather than using the prepend slot, which has some weird customized margin that's not well-suited for this purpose. I've edited your code to achieve the effect that you want - https://codepen.io/CodingDeer/pen/LYPbPxr.
I've also put the snippet here but the icon is not working here for some reason.
<!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/[email protected]/css/materialdesignicons.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/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/[email protected]/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/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>
Upvotes: 1