$ npm install vue-input-autowidth@next --save
# or...
$ yarn add vue-input-autowidth@next
import { createApp } from 'vue'
import App from './App.vue'
import { plugin as VueInputAutowidth } from 'vue-input-autowidth'
createApp(App).use(VueInputAutowidth).mount("#app")
import { directive as VueInputAutowidth } from 'vue-input-autowidth'
export default {
directives: { autowidth: VueInputAutowidth },
setup() {
...
},
}
<input
type="text"
placeholder="Watch me change size with my content!"
v-model="msg"
v-autowidth
/>
You can pass various options to the directive
<input
type="text"
placeholder="An example with custom options"
v-model="msg"
v-autowidth="{
minWidth: '75px',
maxWidth: '86%',
comfortZone: '1ch',
watchWindowSize: true,
}"
/>