Textarea / 文本输入框
获取用户输入的多行文本。
基础的
基础示例。
禁用
禁用文本框所有交互。
状态
通过色彩区分不同的状态
事件
捕获文本框的输入事件
与 useInput 组合
通过 hooks 以更简单的方式驱动文本框。
命令式 API
使用非受控方式更新组件。
APIs / 接口文档
Textarea.Props[别名: Input.Textarea]
| 属性 | 描述 | 类型 | 推荐值 | 默认 |
|---|---|---|---|---|
| value | 设置文本框的值 | string | - | - |
| initialValue | 文本框的初始值 | string | - | - |
| placeholder | 占位文本 | string | - | - |
| status | 文本框当前状态 | TextareaTypes | TextareaTypes | default |
| readOnly | 是否以只读方式显示 | boolean | - | false |
| disabled | 是否禁用文本框 | boolean | - | false |
| onChange | 文本变化事件 | (e: React.ChangeEvent) => void | - | - |
| resize | CSS 属性 | CSSResize | CSSResize | none |
| ... | 原生属性 | TextareaHTMLAttributes | 'form', 'id', 'className', ... | - |
useInput
type useInput = (initialValue: string) => {
state: string
setState: Dispatch<SetStateAction<string>>
currentRef: MutableRefObject<string>
reset: () => void
bindings: {
value: string
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void
}
}
TextareaTypes
type TextareaTypes = 'default' | 'secondary' | 'success' | 'warning' | 'error'
CSSResize
type CSSResize = 'none' | 'both' | 'horizontal' | 'vertical' | 'initial' | 'inherit'
文档贡献者