Skip to content

Input

Enter characters using mouse or keyboard.

Basic Input

<script setup>
import { ref } from 'vue'
import Input from '@/components/Input/Input.vue'
const test = ref('')
</script>
<template>
  <Input v-model="test" placeholder="Basic input" />
  <span>{{test}}</span>
</template>

Disabled Input

Use the disabled prop to specify whether the input is disabled.

<script setup>
import { ref } from 'vue'
import Input from '@/components/Input/Input.vue'
const test = ref('some text')
</script>
<template>
  <Input v-model="test" disabled />
</template>

Size Variants

Use the size prop to change the size of the input box. Besides the default size, there are two other options: large and small.

<script setup>
import { ref } from 'vue'
import Input from '@/components/Input/Input.vue'
const test = ref('')
</script>
<template>
  <div class="size-holder">
    <Input v-model="test" placeholder="Large Input" size="large">
    </Input>
    <Input v-model="test" placeholder="normal Input">
    </Input>
    <Input v-model="test" placeholder="small Input" size="small">
    </Input>
  </div>
</template>
<style scoped>
.size-holder {
  display: flex;
  align-items: center;
}
</style>

Compound Input

You can prepend or append elements such as labels or buttons to the input box using the prepend and append slots.
Use the prefix and suffix slots to add elements inside the input.

Https://
.com
<script setup>
import { ref } from 'vue'
import Input from '@/components/Input/Input.vue'
import Icon from '@/components/Icon/Icon.vue'
const test = ref('')
</script>
<template>
  <Input v-model="test" placeholder="prepend append">
    <template #prepend>Https://</template>
    <template #append>.com</template>
  </Input>

  <Input v-model="test" placeholder="prefix suffix">
    <template #prefix>
      <Icon icon="fa-user" />
    </template>
    <template #suffix>
      <Icon icon="fa-user" />
    </template>
  </Input>
</template>

Textarea

For entering multiline text, use a resizable input box.
Add the type="textarea" prop to convert the input into a native textarea element.

<script setup>
import { ref } from 'vue'
import Input from '@/components/Input/Input.vue'
const test = ref('')
</script>
<template>
  <Input v-model="test" placeholder="Textarea" type="textarea">
  </Input>
</template>

Password Input

Use the show-password prop to enable a toggleable password visibility button.

<script setup>
import { ref } from 'vue'
import Input from '@/components/Input/Input.vue'
const test = ref('')
</script>
<template>
  <Input v-model="test" placeholder="Password text field, can be toggled" showPassword/>
</template>

Clearable Input

Use the clearable prop to allow one-click clearing of the input box.

<script setup>
import { ref } from 'vue'
import Input from '@/components/Input/Input.vue'
const test = ref('')
</script>
<template>
  <Input v-model="test" clearable placeholder="Clear"/>
</template>

Props

NameDescriptionTypeDefault
typeNative input type'string''text'
model-value / v-modelBound valuestring
disabledWhether the input is disabledbooleanfalse
placeholderPlaceholder text for the inputstring
sizeSize of the input (only applies when type is not 'textarea')'large' | 'small'
show-passwordWhether to show the toggle password iconbooleanfalse
clearableWhether to show a clear (reset) buttonbooleanfalse
readonlyNative readonly attributebooleanfalse
autofocusNative autofocus attributebooleanfalse
autocompleteNative autocomplete attributestring'off'

Events

NameDescriptionType
blurTriggered when the input loses focus(e: FocusEvent) => void
focusTriggered when the input gains focus(e: FocusEvent) => void
changeTriggered when the input loses focus and value changes(e: string) => void
inputTriggered when the input value changes(e: string) => void
clearTriggered when the clear button is clicked() => void

Slots

NameDescription
prefixContent before the input
suffixContent after the input
prependContent prepended to input
appendContent appended to input

Exposes

NameDescriptionType
refInput or textarea DOM elementRef<HTMLInputElement | HTMLTextAreaElement>