JGuang

Input

Input · Arco Design

Preview
npm install @arco-design/web-react@2.66.18

Input

The basic form components have been expanded on the basis of native controls and can be used in combination.

Install

npm install @arco-design/web-react@2.66.18

Import @arco-design/web-react/dist/css/arco.css at the entry and set the locale with ConfigProvider. React 19 projects must also import @arco-design/web-react/es/_util/react-19-adapter first, or imperative APIs such as Message and Modal cannot render.

Examples

  • Basic: Input content via mouse or keyboard.
  • Status: Different Input status.
  • Size: Input defines four sizes (mini, small, default, large), which are 24px, 28px, 32px, and 36px.
  • Front/Post Label: Specify addBefore/addAfter to add elements before/after the input box.
  • Prefix/Suffix: Add a prefix(suffix) in the input box by specifying prefix(suffix).
  • Search Box: Input box with search button for content retrieval.
  • Search Box with Loading: Through the loading property, you can set the search box to display loading when onSearch.
  • Input Group: Input content via mouse or keyboard.
  • Length Limit: Set maxLength to limit the maximum number of words, and use showWordLimit to display word count statistics. Setting maxLength.errorOnly will not limit the number of words entered by the user, but if the maximum number of words is exceeded, an error status will be displayed. It is worth noting that if showWordLimit is configured, then you cannot use suffix.
  • Textarea: A textarea input example.
  • Autosize Textarea: Specify autoSize, the text field will automatically adjust the height of the text field according to the input text. If you specify autoSize={{ minRows, maxRows }}, you can also specify the minimum/maximum number of rows.
  • Password: Used for password input.
  • Normalize Value: Format the value entered by the user at the specified time, and when the previous and subsequent values are inconsistent, onChange will be triggered
  • Auto Width: Through the autoWidth attribute, you can set the width of Input to adapt to the text.

Examples come from the official Arco Design repository (MIT) at the commit published as npm 2.66.18. Some use online images or upload endpoints; network requests are disabled in previews.

API

Input

Input Accept all native attribute values

PropertyDescriptionTypeDefaultValueVersion
allowClearWhether allow clear valueboolean--
disabledWhether the input is disabledboolean--
errorWhether the input is error.(Deprecated, removed in the next major version, use status='error' instead)boolean--
readOnlyWhether the input is readOnlyboolean--
showWordLimitWith maxLength, Show word count.boolean--
defaultValueThe initial input contentstring--
placeholderInput box prompt textstring--
valueThe input content valuestring--
autoWidthauto width. minWidth defaults to 0, maxWidth defaults to 100%| boolean| { minWidth?: CSSProperties['minWidth']; maxWidth?: CSSProperties['maxWidth'] }-2.54.0
normalizeTriggerSpecify the timing of normalize execution('onBlur' | 'onPressEnter')[]['onBlur']2.50.0
sizeThe size of the input box'mini' | 'small' | 'default' | 'large'default-
statusStatus'error' | 'warning'-2.45.0
addAfterThe label text displayed after (on the right side of) the input fieldReactNode--
addBeforeThe label text displayed before (on the left side of) the input fieldReactNode--
clearIconConfigure the icon of the clear button when allowClear.ReactNode-2.50.0
prefixThe prefix icon or text for the InputReactNode--
suffixThe suffix icon or text for the InputReactNode--
afterStyleThe additional css style of the addAfter elementobject--
beforeStyleThe additional css style of the addBefore elementobject--
classNameAdditional css classstring | string[]--
heightCustom input heightnumber | string--
maxLengthThe max content length;After setting errorOnly to true, if maxLength is exceeded, the error status will be displayed, and user input will not be restricted.number | { length: number; errorOnly?: boolean }-errorOnly in 2.23.0
styleAdditional styleCSSProperties--
normalizeFormat the value entered by the user at the specified time, and when the previous and subsequent values are inconsistent, onChange will be triggered(value: string) => string-2.50.0
onChangeCallback when user input(value: string, e) => void--
onClearCallback when click clear button() => void--
onPressEnterCallback when press enter key(e) => void--

Input.TextArea

PropertyDescriptionTypeDefaultValueVersion
allowClearWhether allow clear the contentboolean-2.2.0
disabledWhether the textarea is disabledboolean--
errorWhether the textarea is error.(Deprecated, removed in the next major version, use status='error' instead)boolean--
defaultValueTo set default valuestring--
placeholdertextarea placeholderstring--
valueTo set valuestring--
statusStatus'error' | 'warning'-2.45.0
clearIconConfigure the icon of the clear button when allowClear.ReactNode-2.50.0
autoSizeHeight autoSize featureboolean | { minRows?: number; maxRows?: number }--
classNameAdditional css classstring | string[]--
maxLengthThe max content length;After setting errorOnly to true, if maxLength is exceeded, the error status will be displayed, and user input will not be restricted.number | { length: number; errorOnly?: boolean }-errorOnly in 2.23.0
styleAdditional styleCSSProperties--
wrapperStyleWith showWordLimit, a div will be outside the textarea tag, and wrapperStyle is used to configure the style of it.CSSProperties--
wordLimitPositionThe position of the word count'inside' | 'outside'inside2.66.14
onChangeCallback when user input(value: string, e) => void--
onClearCallback when click clear button() => void-2.2.0
onPressEnterCallback when press enter key(e) => void--

Input.Group

PropertyDescriptionTypeDefaultValue
compactWhether to use compact modeboolean-
classNameAdditional css classstring | string[]-
styleAdditional styleCSSProperties-

Input.Search

Contains all the parameters of the Input component

PropertyDescriptionTypeDefaultValueVersion
loadingShow loading status when searchingboolean-2.6.0
searchButtonSearch buttonboolean | ReactNode-ReactNode in 2.6.0
onSearchCallback when click search button(value: string) => void--

Input.Password

Contains all the parameters of the Input component

PropertyDescriptionTypeDefaultValue
defaultVisibilityTo set default visibilityboolean-
visibility-boolean-
visibilityToggleWhether to display the button to switch the visible state of the passwordboolean-
onVisibilityChangeCallback when visibility changes(visibility: boolean) => void-

Method

PropertyDescriptionTypeDefault
focusGet focusFunction-
blurRemove focusFunction-

Demo

<Input ref={(ref) => (this.input = ref)} />;

this.input.focus();
this.input.blur();