Skip to content

Input ​

Brief Introduction ​

The input component is used for users to enter text content. mengyue-components has encapsulated it and performed vitest testing. You can use <MYInput></MYInput> to implement an input box.

Basic Usage ​

Use modelValue to bind the value of the input box.

Code Demo
展开代码

Input Type ​

Use the type property to set the type of the input box, such as text, password, etc.

Code Demo
展开代码

Size Control ​

Use the width and height properties to customize the dimensions of the input box.

Code Demo
展开代码

State Control ​

disabled ​

Disable the input box:

Code Demo
展开代码

clearable ​

Show clear button:

Code Demo
展开代码

showPassword ​

Toggle password visibility:

Code Demo
展开代码

Input Restrictions ​

Length Limit ​

Use minLength and maxLength to limit input length:

Code Demo
展开代码

Word Count ​

Use wordLimit to display word count:

Code Demo
0/20
展开代码

Custom Colors ​

textColor ​

Custom text color:

Code Demo
展开代码

placeholderColor ​

Custom placeholder color:

Code Demo
展开代码

Multiline Text ​

Use tag="textarea" for multiline text input:

Code Demo
展开代码

Combined Usage ​

Combine multiple properties:

Code Demo
0/15
展开代码

API Reference ​

Props ​

ParameterDescriptionTypeOptionsDefault
typeInput typestringtext/password etc.text
tagTag typestringinput/textarea etc.input
widthWidthstring | number—100%
heightHeightstring | number—30px
disabledWhether disabledboolean—false
clearableWhether clearableboolean—false
showPasswordWhether to show password toggleboolean—false
placeholderPlaceholder textstring—''
modelValueBound valuestring—''
minLengthMinimum input lengthnumber——
maxLengthMaximum input lengthnumber | string——
wordLimitWhether to show word countboolean—false
textColorText colorstringHex or named color—
placeholderColorPlaceholder colorstringHex or named color—

Type Definitions ​

typescript
interface InputProps {
  type?: string;
  tag?: string;
  width?: string | number;
  height?: string | number;
  disabled?: boolean;
  clearable?: boolean;
  showPassword?: boolean;
  placeholder?: string;
  modelValue?: string;
  minLength?: number;
  maxLength?: number | string;
  wordLimit?: boolean;
  textColor?: string;
  placeholderColor?: string;
}

Released under the MIT License.