Single-line input
WdInput
Applicable Scenarios
For single-line content input.
Basic Capabilities Description
Bind a "Text" type field. After the form container is bound to the data model, text fields in the model will be automatically rendered as single-line input components, enabling single-line data entry. Configurable options include input value, placeholder text, component size, and whether to horizontally fill the space (component size and whether to horizontally fill the space are effective on PC but not on mobile).
Supports personalized configuration for titles, including title content, alignment, whether to wrap text (when enabled, the title wraps to the next line if it exceeds one line; when disabled, the title is truncated if it exceeds one line), title position, width, and tooltip text.

- Supports personalized configuration for input fields, including whether to display a clear button, prefix/suffix text, prefix/suffix icons, hint text below, whether to display as password, keyboard type, whether to show character count, whether to automatically gain focus, whether to display underlines on mobile, and whether to display input boxes on PC.

Note:
- Prefix and suffix text in forms will be submitted to the data model along with the input content.
- Size configuration applies only to the PC side;
- If a component is within a form container, its size, title alignment, position, line wrapping, and width will default to the property configuration of the form container
- Validation rule configuration: supports required fields, maximum length, custom validation rules, and validation messages. Component-supported validation rules include: ID card, bank card, email, number, Chinese characters, URL, license plate, Chinese name, English name, username, address, date, numeric verification code (4-8 digits), other verification codes (Chinese/English characters with 4+ digits), code, Hong Kong and Macau Pass, Taiwan Pass (China), passport, amount, mobile number, landline phone.
Mobile numbers and landline phones comply with universal phone protocols for regular expression validation rules.
^(\+\d{1,4}[\s-]?)?(\(?\d{1,4}\)?[\s-]?)?(\d{1,4}[\s-]?)?(\d{1,4})?\d{1,9}(\s?(x|ext)\s?\d{1,6})?$
To validate carrier-specific numbers, you can select custom rules to configure regular expressions for validation. For example: Chinese mainland mobile numbers
^1[3-9]\d{9}$
To learn more about form component usage scenarios, refer to the Form Common Scenario Practice Guide
Example
Interactive Preview
Component Styling
Component Size
Component Alignment
Component Password Input
Component Input Status
Style API Example
#wd-page-root .wd-form-item .wd-input-input {
border-color: cyan;
color: cyan;
background-color: black;
border-width: 2px;
border-radius: 6px;
}
Properties
External properties received by the component
Property Name | Property Identifier | Type | Description |
|---|
| Display Headlines | labelVisible | boolean | Default value: true |
| Title alignment | labelAlign | string | In the scenario, the form by default follows the title alignment configuration of the form container. |
| Line break in heading | labelWrap | boolean | If the title content is too long when closed, show one line with overflow omitted; when enabled, show with line breaks. In form scenarios, it follows the form container's title line break configuration by default. |
| Title position | layout | string | Set title display position in form component. In the scenario, it follows the title position configuration of the form container by default. |
| Title width | labelWidth | string | In the scenario, the form follows the title width configuration of the form container by default. |
| Heading Note | labelTips | string | Configure tooltip content for the heading |
| WeChat Mini Program nickname retrieval | isNickNameType | boolean | Take effect only in Mini Program |
| Distance between cursor and keyboard | cursorSpacing | number | Specify the distance between the cursor and the keyboard. Use the smaller of the distance from the textarea to the bottom and the distance specified by cursor-spacing as the distance between the cursor and the keyboard; takes effect only in the mini program. |
| Display clear button | clearable | boolean | Enabled, quick clear button is provided by Default value: true |
| Prefix text | before | string | The input box in the form displays the prefix text. In the form submission scenario, the prefix text is submitted as part of the form content to the data model. |
| suffix text | after | string | The input box in the form displays suffix text. In the scenario of form submission, the suffix text is submitted as form content to the data model together. |
| Component value contains prefix and suffix text | isUnionValue | boolean | Get component value, whether the value contains prefix and suffix text Default value: true |
| Prefix icon type | prefixType | string | Select icon type Example: "" |
| Prefix icon | prefixIcon | string | Show icon before the form input box Example: "success" |
| Prefix icon | prefixSrc | string | Set custom icon address |
| suffix icon type | suffixType | string | Select icon type Example: "" |
| suffix icon | suffixIcon | string | Show icon in the form input box Example: "success" |
| suffix icon | suffixSrc | string | Set custom icon address |
| Prompt. | extra | string | The prompt content is displayed below the input box after configuration. |
| Show Password | password | boolean | Show input in the form of a password |
| input keyboard type | type | string | Control the display form of the mobile terminal input keyboard Default value: "text" |
| Switch input value by input keyboard | isConvert | boolean | Control whether to automatically convert input values based on the input keyboard type Default value: true |
| Character count | counterVisible | boolean | |
| automatically obtain focus | focus | boolean | After enabled, the cursor automatically positions to the input box when page loading completes. |
| Display underscore on mobile terminal | borderedH5 | boolean | After closing, the mobile terminal does not show the bottom underline Default value: true |
| Display input border on PC | borderedPc | boolean | After closing, do not display input border on PC Default value: true |
| Maximum length | maxLength | number | Default value: 140 |
| Verification rule | rules | array | Default value: [] |
| Status. | status | string | Example: "edit" |
| Required | required | boolean | |
| Required identifier | requiredFlag | boolean | Enabled, the component will display a required asterisk tag if mandatory. Default value: true |
| Required validation note | requiredMsg | string | Example: "该项为必填项" |
| Bound field | name | string | The Key value of a form field is used to match the field identifier of the data model when submitting data. It must be unique within the form. |
| Title content. | label | string | Example: "标题" |
| input value | inputValue | string | Example: "" |
| Placeholder text | placeholder | string | Example: "请输入" |
| PC component dimension | size | string | Size configuration is only applicable to PC and takes effect by default in form container scenarios. |
| Template | template | string | Preset template for input box style Example: "inputBox" |
Events
Events exposed by the component. You can listen to component events to trigger external actions
Event Name | Event Code | Event Output Parameters event.detail | Applicable Scenarios | Description |
|---|
| value change | change | object
| Compatible with all platforms | Trigger when a user modifies a component value |
| focus | focus | object
| Compatible with all platforms | - |
| Out of focus | blur | object
| Compatible with all platforms | - |
| confirm | confirm | object
| Compatible with all platforms | Trigger on keyboard input of enter in web |
| Purge content | clear | object
| Compatible with all platforms | - |
| Text/icon click around the input box | inputAdornmentClick | object
| Compatible with all platforms | 点击的元素类型,[ 'beforeText' | 'afterText' | 'prefix' | 'suffix'] |
Properties API
Through the Property API, you can access the internal state and property values of components. You can access internal values using$w.componentId.propertyName, such as $w.input1.value. For details, please refer to Property API
Read-only Property Name | Property Identifier | Type | Description |
|---|
| Bound field | name | string | The Key value of a form field is used to match the field identifier of the data model when submitting data. It must be unique within the form. |
| Title content. | label | string | |
| input value | value | string | |
| Prefix text | before | string | The input box in the form displays the prefix text. In the form submission scenario, the prefix text is submitted as part of the form content to the data model. |
| suffix text | after | string | The input box in the form displays suffix text. In the scenario of form submission, the suffix text is submitted as form content to the data model together. |
| Required | required | boolean | |
| Indicates whether to display | visible | boolean | Whether to display the component |
| Whether to disable | disabled | boolean | Component Disabled |
| Specify whether it is read-only or not. | readOnly | boolean | Whether the component is read-only |
Method API
Through the Method API, you can programmatically trigger internal methods of components, such as submitting forms, displaying popups, etc. You can call component methods using $w.componentId.methodName, such as $w.form1.submit()
Method Name | Method Identifier | Parameters | Method Description |
|---|
| set value | setValue | string值 | 通过 $w.id1.setValue("weda") 设置组件值 |
| Show/Hide Settings | setVisible | boolean显示 | Set the component to hidden via $w.id1.setVisible(false) |
| Set Disabled | setDisabled | boolean禁用 | Set the component to disabled with $w.id1.setDisabled(true) |
| Clear value | clearValue | Clear the component value with $w.id1.clearValue() | |
| Set as read-only | setReadOnly | boolean只读 | Set the component to read-only via $w.id1.setReadOnly(true) |
| Trigger validation | handleValidate | Validate the component value via $w.id1.handleValidate() | |
| Clear verification | clearValidate | Clear component validation via $w.id1.clearValidate() |
Style API
Through the Style API, you can override the styles of internal elements in components to achieve customization. For example, in the low-code editor, you can write styles for all button components using #wd-page-root .wd-btn, and control individual component styles with :scope. For detailed instructions, please refer toStyle API
Name | Class Name | Description and Examples |
|---|
| root element | .wd-input-root | Outermost component element |
| H5 root element | .wd-h5-input-root | Settable root element style for the H5 side |
| PC-side root element | .wd-pc-input-root | Settable root element style for the PC side |
| Mini program root element | .wd-mp-input-root | Settable root element style for mini program |
| Component title style | .wd-input-root .wd-form-item-wrap__label | Component title element |
| form control root node style | .wd-input-root .wd-form-item-wrap__control | Set form control root element style |
| Input box style - editing status | .wd-input-root .wd-form-input-wrap | Component border, margin style, background color, font size, font color |
| Editing status - Input box style (gain focus) | .wd-input-root .wd-form-input-wrap.is-focused | Editing status - Input box style (gain focus) |
| Editing status - Placeholder text style | .wd-input-root input::placeholder, .wd-input-root .weui-input__placeholder | Set placeholder text style |
| Editing status - Verification information | .wd-input-root .wd-g-text-error | Set component verification information style |
| prompt text | .wd-input-root .wd-form-item__help-text | Set the text style of the component prompt |
| Disabled state - Input box style | .wd-input-root .wd-form-input-wrap.is-disabled | Component disabled style |
| read-only status - form value style | .wd-input-root .wd-form-item__readonly-value | Set component read-only status |
| Prefix text style | .wd-input-root .wd-form-input-group__addon-left | Set component prefix text style |
| Suffix text style | .wd-input-root .wd-form-input-group__addon-right | Set component suffix text style |
Version Changes
- Property Changes
- Style Changes
- widget api Changes