Textarea
从 Base Textarea 协议投影出的 Shadcn Textarea。
本页常规演示显式采用 Shadcn Rhea 外观,示例代码保持一致;这不修改公共组件的兼容默认值,也不代表全部浏览器、原生宿主和视觉验收已完成。Surface/Text 等中性原子仍保留各自公开语义,外观主题由消费组合提供。
这个条目展示 Proto UI 中当前的 shadcn textarea 实现。
协议归 Base Textarea 所有:controlled 与 uncontrolled value、归一化的 input/change/IME 事件、rows、maxLength、readOnly 等 native props、accessibility 投影,以及 focus 与 blur。它只物化一个 host-owned 的多行编辑器,shadcn 层只增加呈现——field 尺寸、边框、focus ring 与 disabled 处理。
投射是 contentless 的。authored children 不会成为第二个编辑器,本切片也不引入 form workflow、validation message、auto-resize 或富文本行为。
演示是三个编辑器:一个非受控备注(rows 4、maxLength 240)、一个禁用编辑器,以及一个仍可聚焦的只读编辑器。
npx @proto.ui/cli@latest add wc shadcn-textarea
把 wc 换成 react、vue 或 vue2,即可生成对应宿主的 facade。
传入 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 | '' |
Root 暴露 value、disabled、readOnly、focused、focusVisible、composing,以及 valueChange、change 和 composition 事件。作者写入的 children 不是第二个编辑器。