跳转到内容
Page

Textarea

多行文本输入框。

import { Textarea } from "@pelagornis/page/components";

上方预览渲染的就是这个文件。把它复制到 src/components/ 即可开始使用。

src/components/TextareaExample.tsx
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>
);
}

Textarea 可以直接写在 .mdx 页面中。在 frontmatter 下方导入即可。它在服务器端渲染,不需要 client 指令。

src/content/docs/example.mdx
---
title: Example
---
import { Textarea } from "@pelagornis/page/components";
<Textarea placeholder="Write a comment…" rows={4} aria-label="Comment" />

pageMarkdoc() 会为这个组件注册 textarea 标签。在 markdoc.config.mjs 中添加一次预设(见在 Markdoc 中使用),就能在任意 .mdoc 页面中使用该标签。

src/content/docs/example.mdoc
{% textarea placeholder="Write a comment…" rows=4 ariaLabel="Comment" /%}

属性的名称和取值与 React props 相同。

组件的组成部分,以及每个部分渲染的 data-refineui 角色。

部件角色
roottextarea