Skip to content

Input ​

Basic usage ​

vue
<template>
  <lh-input v-model="text" placeholder="Type here" />
  <lh-input v-model="text" type="textarea" :rows="3" autosize placeholder="Multi-line" />
  <lh-input v-model="text" type="password" placeholder="Password" />
</template>

<script setup lang="ts">
import { ref } from 'vue'
const text = ref('')
</script>

Placeholder styling (required on MP) ​

The Mini Program does not support ::placeholder

The WXSS of the WeChat Mini Program does not support the ::placeholder pseudo-element. Pass placeholder styling in via props and do not write ::placeholder in CSS (the build-time guard also blocks it).

vue
<lh-input placeholder="Type here" placeholder-style="color: #999; font-size: 13px" />
<!-- or use a class name -->
<lh-input placeholder="Type here" placeholder-class="my-placeholder" />

With icons and states ​

vue
<template>
  <lh-input v-model="text" prefix-icon="search" placeholder="Search" clearable />
  <lh-input v-model="text" suffix-icon="close" placeholder="Suffix icon" />
  <lh-input v-model="text" state="error" placeholder="Failed validation state" />
  <lh-input v-model="text" :maxlength="20" show-word-limit placeholder="Word counter" />
</template>

Props ​

PropDescriptionTypeDefault
modelValue (v-model)Bound valuestring—
typeType'text' | 'textarea' | 'password' | 'number' | 'email' | 'url' | 'tel' | 'date' | 'time''text'
sizeSize'small' | 'medium' | 'large'—
disabledDisabledbooleanfalse
readonlyRead-onlybooleanfalse
placeholderPlaceholder textstring—
placeholderStylePlaceholder inline style (replaces ::placeholder)string—
placeholderClassPlaceholder class name (pick one of placeholderStyle or this)string—
maxlengthMaximum lengthnumber—
minlengthMinimum lengthnumber—
showWordLimitShow the word counterbooleanfalse
clearableClearablebooleanfalse
prefixIconPrefix iconLhIconName—
suffixIconSuffix iconLhIconName—
stateValidation state'error' | 'success' | 'warning'—
nameNative name (for form collection)string—
passwordPassword modebooleanfalse
rowstextarea rowsnumber—
autosizetextarea auto-height (the auto-height of the MP textarea)booleanfalse
labelLabel textstring—
customClassCustom class namestring—
themeVarsComponent-level theme variablesRecord<string, string>—
sxQuick layout propsLhSxProps—

Events ​

EventDescriptionCallback parameters
update:modelValueValue changed(value: string)
inputInput (takes event.detail.value)(value: string)
blurBlur—
focusFocus—
clearCleared—

Differences from the Vue3 version

autocomplete / autofocus / resize / form / tabindex / nativeType / inputStyle have no counterparts on the Mini Program and are not implemented in this library. autosize uses the auto-height attribute of the MP textarea.