Duostrap Textarea
沿用归档 Duostrap 输入框视觉风格与经典表单校验配色的多行文本输入组件。
Duostrap Textarea 将归档版本的经典文本框样式(4px 圆角、内阴影、#52a8ec 聚焦光晕与 #eee 禁用底色)应用于 Base Textarea,在 Web 上渲染单一原生多行编辑器,并在深色宿主中保持经典的归档浅色配色。
Web Components React Vue Vue 2
正在加载交互示例… 正文和源码已可阅读,交互控件就绪后会显示在这里。
<wc-duostrap-textarea-root
placeholder="Type your message here."
aria-label="Message"
rows="4"
></wc-duostrap-textarea-root>当前以工作区源码提供,可从 @proto.ui/prototypes-duostrap/textarea(以及表单组合入口 @proto.ui/prototypes-duostrap/field)导入。查看已实现的子集。
import { DuostrapTextareaRoot } from '../proto-ui/components/react';<DuostrapTextareaRoot placeholder="Type your message here." rows={4} />- 值与输入事件:支持受控
value与非受控defaultValue,统一处理valueChange、change与 IME 组合输入事件,并提供resetValue()、focusSelf()与blurSelf()方法。 - 行数与换行:通过
rows和wrap控制初始显示行数与换行策略,默认支持垂直拉伸(resize-y)与 64px 最小高度。 - 表单字段组合:搭配
Field、FieldLabel、FieldDescription、FieldError与FieldTextarea使用,可自动接入标签关联及经典#953b39/#d59392错误态样式。
组合 Field、FieldLabel、FieldTextarea 与 FieldDescription 呈现经典的 Bootstrap 表单块。
Web Components React Vue Vue 2
正在加载交互示例… 正文和源码已可阅读,交互控件就绪后会显示在这里。
<wc-duostrap-field-root>
<wc-duostrap-field-label>Message</wc-duostrap-field-label>
<wc-duostrap-field-textarea
placeholder="Type your message here."
rows="4"
></wc-duostrap-field-textarea>
<wc-duostrap-field-description>
Enter your message below.
</wc-duostrap-field-description>
</wc-duostrap-field-root>禁用状态下文本框呈现经典的 #eee 浅灰底色与 not-allowed 光标。
Web Components React Vue Vue 2
正在加载交互示例… 正文和源码已可阅读,交互控件就绪后会显示在这里。
<wc-duostrap-field-root disabled>
<wc-duostrap-field-label>Message</wc-duostrap-field-label>
<wc-duostrap-field-textarea
placeholder="Type your message here."
rows="3"
></wc-duostrap-field-textarea>
</wc-duostrap-field-root>通过 Field 的 invalid 与 errors 属性触发 Duostrap 经典的 #953b39 边框与 #d59392 聚焦光晕。
Web Components React Vue Vue 2
正在加载交互示例… 正文和源码已可阅读,交互控件就绪后会显示在这里。
<wc-duostrap-field-root invalid>
<wc-duostrap-field-label>Message</wc-duostrap-field-label>
<wc-duostrap-field-textarea
placeholder="Type your message here."
rows="3"
></wc-duostrap-field-textarea>
<wc-duostrap-field-error></wc-duostrap-field-error>
</wc-duostrap-field-root>与经典 Duostrap 按钮组合构建提交表单。
Web Components React Vue Vue 2
正在加载交互示例… 正文和源码已可阅读,交互控件就绪后会显示在这里。
<div class="flex flex-col items-start gap-2">
<wc-duostrap-textarea-root
placeholder="Type your message here."
aria-label="Message"
rows="3"
></wc-duostrap-textarea-root>
<wc-duostrap-button>Send message</wc-duostrap-button>
</div>以下属性属于 Root(传入 value 可进入受控模式;未限制长度时 minLength 与 maxLength 为 -1):
| 属性 | 类型 | 默认值 |
|---|---|---|
value | string undefined | 非受控 |
defaultValue | string | '' |
disabled | boolean | false |
readOnly | boolean | false |
placeholder | string | '' |
rows | number | 2 |
required | boolean | false |
name | string | '' |
autoComplete | string | '' |
minLength | number | -1 |
maxLength | number | -1 |
wrap | 'soft' 'hard' | 'soft' |
ariaLabel | string | '' |
labelledBy | string | '' |
describedBy | string | '' |
- 暴露状态:
value、disabled、readOnly、focused、focusVisible、composing(在FieldTextarea中额外暴露invalid与pending)。 - 暴露方法:
focusSelf(options?)、blurSelf()、resetValue()。 - 事件:
valueChange、change、compositionStart、compositionUpdate、compositionEnd。