Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there specific number input component in Vuetify?

I've seen a component in Element UI for managing the amount of items, it's over here:

https://element.eleme.io/#/en-US/component/input-number

I would want to use something like that in Vuetify, but I cannot find a similar component or even similar style example in Material Design. What's the best way to achieve it?

like image 547
Tutu Kaeen Avatar asked Dec 03 '18 07:12

Tutu Kaeen


People also ask

What is lazy validation Vuetify?

lazy-validation. boolean. false. If enabled, value will always be true unless there are visible validation errors. You can still call validate() to manually trigger validation.

What is ref in Vuetify?

A ref allows us to access internal methods on a component, for example, <v-form ref="form"> . this. $refs.


2 Answers

Yes there is:

<v-text-field   v-model="numberValue"   hide-details   single-line   type="number" /> 

Check out slider component docs for a working example.

like image 136
yukashima huksay Avatar answered Oct 04 '22 18:10

yukashima huksay


Update: This answer pertains to version 1 of Vuetify, yukashima huksay's answer is correct for newer versions of Vuetify.

Setting the type attribute to type="number" is the way to go.

Original:

You could just make your own:

new Vue({    el: '#app',   data () {      return {        foo: 0      }   },   methods: {     increment () {       this.foo = parseInt(this.foo,10) + 1     },     decrement () {       this.foo = parseInt(this.foo,10) - 1     }   } })
<link href='https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900|Material+Icons' rel="stylesheet"> <link href="https://cdn.jsdelivr.net/npm/vuetify/dist/vuetify.min.css" rel="stylesheet"> <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script> <script src="https://cdn.jsdelivr.net/npm/vuetify/dist/vuetify.js"></script>  <div id="app">     <v-app>       <v-content>         <v-container>           <v-text-field v-model="foo" type="number" label="Number" append-outer-icon="add" @click:append-outer="increment" prepend-icon="remove" @click:prepend="decrement"></v-text-field>         </v-container>       </v-content>     </v-app>   </div>
like image 39
Brian Lee Avatar answered Oct 04 '22 17:10

Brian Lee