Textarea
多行文本输入框。
导入
“导入”部分import { Textarea } from "@pelagornis/page/components";示例
“示例”部分上方预览渲染的就是这个文件。把它复制到 src/components/ 即可开始使用。
import { Stack, Textarea } from "@pelagornis/page/components";
export default function TextareaDemo() { return ( <Stack gap="sizeSmall" className="w-full max-w-sm"> <Textarea placeholder="Write a comment…" rows={4} aria-label="Comment" fullWidth /> <Textarea error defaultValue="Too short" rows={2} aria-label="Error" fullWidth /> </Stack> );}在 MDX 中使用
“在 MDX 中使用”部分Textarea 可以直接写在 .mdx 页面中。在 frontmatter 下方导入即可。它在服务器端渲染,不需要 client 指令。
---title: Example---
import { Textarea } from "@pelagornis/page/components";
<Textarea placeholder="Write a comment…" rows={4} aria-label="Comment" />在 Markdoc 中使用
“在 Markdoc 中使用”部分pageMarkdoc() 会为这个组件注册 textarea 标签。在 markdoc.config.mjs 中添加一次预设(见在 Markdoc 中使用),就能在任意 .mdoc 页面中使用该标签。
{% textarea placeholder="Write a comment…" rows=4 ariaLabel="Comment" /%}属性的名称和取值与 React props 相同。
结构
“结构”部分组件的组成部分,以及每个部分渲染的 data-refineui 角色。
| 部件 | 角色 |
|---|---|
root | textarea |
参考
“参考”部分- 设计指南和令牌细节见 RefineUI · Textarea。
- 通用规则见在 MDX 中使用和在 Markdoc 中使用。