Skip to content

Input

Input component for collecting user input data.

For number input, see InputNumber component For multi-line text, see Textarea component

Basic Usage

The simplest input form with two-way data binding via v-model.

Current value: (empty)
vue
<template>
  <u-input v-model="value1" placeholder="Please enter content"></u-input>
  <div>Current value: {{ value1 || '(empty)' }}</div>
</template>

<script setup>
  import { ref } from 'vue';
  const value1 = ref('');
</script>

Max Length

Limit the maximum number of characters with the maxlength attribute.

vue
<template>
  <u-input :maxlength="6" placeholder="Max 6 characters"></u-input>
</template>

Prefix & Suffix

Add prefix and suffix content via prefix and suffix attributes, or customize through slots.

.com
vue
<template>
  <u-input placeholder="Please enter content" suffix=".com">
    <template #prefix>
      <u-icon name="search"></u-icon>
    </template>
  </u-input>
</template>

<script setup>
  import { UIcon } from 'ume-ui';
</script>

Password Input

Set type="password" to enable password input mode with toggle visibility support.

password
hi
vue
<template>
  <u-input placeholder="Enter password" type="password"></u-input>
  <u-input placeholder="With prefix" type="password" prefix="password"></u-input>
  <u-input placeholder="With suffix" type="password" suffix="hi"></u-input>
</template>

Sizes

Three input sizes available: small, medium, large.

vue
<template>
  <u-input placeholder="Small" size="small"></u-input>
  <u-input placeholder="Medium" size="medium"></u-input>
  <u-input placeholder="Large" size="large"></u-input>
</template>

Disabled & Readonly

Set disabled state via disabled, readonly state via readonly.

vue
<template>
  <u-input placeholder="Disabled state" disabled></u-input>
  <u-input placeholder="Readonly state" readonly></u-input>
</template>

API

AttributeDescriptionTypeDefault
modelValueBinding valuestring | number-
typeInput typetext | passwordtext
placeholderPlaceholder textstring-
disabledWhether disabledbooleanfalse
readonlyWhether readonlybooleanfalse
clearableWhether clearablebooleanfalse
sizeInput sizelarge | medium | smallmedium
prefixPrefix contentstring-
suffixSuffix contentstring-
maxlengthMaximum lengthnumber | string-
minlengthMinimum lengthnumber | string-

Slots

Slot NameDescription
prefixPrefix content
suffixSuffix content