Skip to content

Input ​

Introduction ​

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

Basic Usage ​

Use modelValue to bind the value of the input field.

Code Demo
展开代码

Input Type ​

The type prop can be used to set the input field type, such as text, password, etc.

Code Demo
展开代码

Size Control ​

Use the width and height props to customize the dimensions of the input field.

Code Demo
展开代码

State Control ​

disabled ​

Disable the input field:

Code Demo
展开代码

clearable ​

Display a 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 Limit ​

Use wordLimit to display character count:

Code Demo
展开代码

Custom Colors ​

textColor ​

Custom text color:

Code Demo
展开代码

placeholderColor ​

Custom placeholder color:

Code Demo
展开代码

Multi-line Text ​

Use tag="textarea" to implement multi-line text input:

Code Demo
展开代码

Combined Usage ​

Combine multiple props:

Code Demo
展开代码

API Reference ​

Props ​

ParameterDescriptionTypeOptionsDefault
typeInput field 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 character countboolean—false
textColorText colorstringSupports hex colors or color names—
placeholderColorPlaceholder colorstringSupports hex colors or color names—

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.