Skip to content

Input

Rules

Basic Example

js
const rule = {
    type:"input",
    title:"Product Name",
    field:"goods_name",
    value:"iphone 7",
    props: {
        placeholder: "Enter product name",
        allowClear: true,
    }
}

Props Configuration Examples

Text Input Box (text)

js
const rule = {
    type:"input",
    title:"Username",
    field:"username",
    props: {
        placeholder: "Enter username",
        allowClear: true,
        size: "medium",
    }
}

Textarea

js
const rule = {
    type:"input",
    title:"Product Description",
    field:"description",
    props: {
        type: "textarea",
        placeholder: "Enter product description",
        autoSize: { minRows: 3, maxRows: 6 },
        showWordLimit: true,
        maxLength: 200,
    }
}

Password Input Box (password)

js
const rule = {
    type:"input",
    title:"Password",
    field:"password",
    props: {
        type: "password",
        placeholder: "Enter password",
        allowClear: true,
    }
}

Clearable Input Box

js
const rule = {
    type:"input",
    title:"Search Keyword",
    field:"keyword",
    props: {
        placeholder: "Enter search keyword",
        allowClear: true,
    }
}

Show Word Count

js
const rule = {
    type:"input",
    title:"Product Description",
    field:"description",
    props: {
        type: "textarea",
        placeholder: "Enter product description",
        maxLength: 200,
        showWordLimit: true,
    }
}

Disabled and Readonly

js
const rule = {
    type:"input",
    title:"Order Number",
    field:"order_no",
    value:"ORD20240101001",
    props: {
        disabled: true,
        // or use readonly: true,
    }
}

Events Examples

Handle Input and Focus Events

js
const rule = {
    type:"input",
    title:"Search Keyword",
    field:"keyword",
    props: {
        placeholder: "Enter search keyword",
        allowClear: true,
    },
    on: {
        change: (value) => {
            console.log('Input value changed:', value);
        },
        input: (value) => {
            console.log('Real-time input:', value);
        },
        blur: () => {
            console.log('Lost focus');
        },
        focus: () => {
            console.log('Gained focus');
        },
        clear: () => {
            console.log('Input cleared');
        },
    },
}

Real-Time Search (Using input Event)

js
const rule = {
    type:"input",
    title:"Search Products",
    field:"keyword",
    props: {
        placeholder: "Enter product name to search",
        allowClear: true,
    },
    inject: true,
    on: {
        input: ($inject, value) => {
            // Auto-search as user types
            if (value && value.length >= 2) {
                // Call search API
                searchProducts(value).then(res => {
                    // Update search results
                    $inject.api.setValue('searchResults', res.data);
                });
            }
        },
    },
}

Linkage Update Other Fields (change Event)

js
const rule = [
    {
        type:"input",
        title:"Product Name",
        field:"goods_name",
        props: {
            placeholder: "Enter product name",
        },
        inject: true,
        on: {
            change: ($inject, value) => {
                // Auto-generate product code
                if (value) {
                    const code = 'GD' + value.substring(0, 3).toUpperCase() + Date.now().toString().slice(-6);
                    $inject.api.setValue('goods_code', code);
                }
            },
        },
    },
    {
        type:"input",
        title:"Product Code",
        field:"goods_code",
        props: {
            disabled: true,
        },
    },
]

Complete configuration items: arco-design_Input

value: String

Props

ParameterDescriptionTypeDefaultVersion
sizeInput box size'mini' | 'small' | 'medium' | 'large''medium'
allow-clearWhether to allow clearing the input boxbooleanfalse
disabledWhether disabledbooleanfalse
readonlyWhether in readonly statebooleanfalse
errorWhether in error statebooleanfalse
placeholderPlaceholder textstring-
max-lengthMaximum length of input value, errorOnly property added in version 2.12.0number | { length: number; errorOnly?: boolean }0
show-word-limitWhether to show word countbooleanfalse
word-lengthMethod for calculating character length(value: string) => number-
word-sliceMethod for character truncation, used together with wordLength(value: string, maxLength: number) => string-2.12.0

Events

Event NameDescriptionParameters
inputTriggered when user inputsvalue: string
changeTriggered only when input box loses focus or Enter is pressedvalue: string
press-enterTriggered when user presses Enter-
clearTriggered when user clicks clear button-
focusTriggered when input box gains focus-
blurTriggered when input box loses focus-

<input-password> Props

ParameterDescriptionTypeDefault
invisible-buttonWhether to show visibility buttonbooleantrue

<input-search> Props

ParameterDescriptionTypeDefaultVersion
search-buttonWhether in post-button modebooleanfalse
loadingWhether in loading statebooleanfalse
disabledWhether disabledbooleanfalse
sizeInput box size'mini' | 'small' | 'medium' | 'large''medium'
button-textText of search button, will replace original icon when usedstring-2.16.0
button-propsProperties of search buttonobject-

<input-search> Events

Event NameDescriptionParameters
searchTriggered when search button is clickedvalue: string

FormCreate is an open-source project released under the MIT License. Free for personal and commercial use.