跳转到内容
Page

Input

带错误和成功状态的单行输入框。

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

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

src/components/InputExample.tsx
import { Input, Stack } from "@pelagornis/page/components";
export default function InputDemo() {
return (
<Stack gap="sizeSmall" className="w-full max-w-sm">
<Input placeholder="Default" aria-label="Default" fullWidth />
<Input size="lg" placeholder="Large" aria-label="Large" fullWidth />
<Input error defaultValue="Invalid value" aria-label="Error" fullWidth />
<Input success defaultValue="Looks good" aria-label="Success" fullWidth />
<Input disabled placeholder="Disabled" aria-label="Disabled" fullWidth />
</Stack>
);
}

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

src/content/docs/example.mdx
---
title: Example
---
import { Input } from "@pelagornis/page/components";
<Input placeholder="you@example.com" aria-label="Email" />

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

src/content/docs/example.mdoc
{% input placeholder="you@example.com" ariaLabel="Email" /%}

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

每个 variant prop 可接受的取值。

Prop取值
sizesm md lg

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

部件角色
rootinput