JGuang

TextArea

TextArea · Ant Design Mobile

Preview
npm install antd-mobile@5.43.0

TextArea

Entering content through the keyboard is the most basic form field wrapper.

Install

npm install antd-mobile@5.43.0

antd-mobile is for mobile web, not React Native or Mini Programs. React 19 projects must register createRoot with unstableSetRender at the entry, or imperative APIs such as Toast and Dialog cannot render. Switch dark mode with <html data-prefers-color-scheme="dark">.

Examples come from the official Ant Design Mobile repository (MIT) at the commit published as npm 5.43.0. Presentation helpers such as DemoBlock are JGuang rewrites, not antd-mobile APIs.

Entering content through the keyboard is the most basic form field wrapper.

When to Use

Long text input that requires wrapping.

Demos

TextArea

Props

NameDescriptionTypeDefault
autoSizeAdaptive content heightboolean | { minRows?: number, maxRows?: number }false
defaultValueInput value by defaultstring-
idid of textarea element, often used in conjunction with labelstring-
maxLengthMaximum number of charactersnumber-
onChangeTriggered when the TextArea content changed(value: string) => void-
placeholderHint textstring-
rowsNumber of rowsnumber2
showCountDisplay the number of words, supports custom renderboolean | ((length: number, maxLength?: number) => ReactNode)false
valueInput valuestring-

In addition, the following native attributes are supported: autoComplete autoFocus disabled readOnly onFocus onBlur onCompositionStart onCompositionEnd onClick

CSS Variables

NameDescriptionDefault
--colorfont color.var(--adm-color-text)
--count-text-alignThe alignment of count text.right
--disabled-colorfont color in disabled status.var(--adm-color-weak)
--font-sizefont size.17px
--placeholder-colorplaceholder font color.var(--adm-color-light)
--text-alignThe alignment of text.left

Ref

NameDescriptionType
blurLet the input box lose focus() => void
clearClear the input content() => void
focusLet the input box get focus() => void
nativeElementNative text-area elementHTMLTextAreaElement | null