Input
带错误和成功状态的单行输入框。
导入
“导入”部分import { Input } from "@pelagornis/page/components";示例
“示例”部分上方预览渲染的就是这个文件。把它复制到 src/components/ 即可开始使用。
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> );}在 MDX 中使用
“在 MDX 中使用”部分Input 可以直接写在 .mdx 页面中。在 frontmatter 下方导入即可。它在服务器端渲染,不需要 client 指令。
---title: Example---
import { Input } from "@pelagornis/page/components";
<Input placeholder="you@example.com" aria-label="Email" />在 Markdoc 中使用
“在 Markdoc 中使用”部分pageMarkdoc() 会为这个组件注册 input 标签。在 markdoc.config.mjs 中添加一次预设(见在 Markdoc 中使用),就能在任意 .mdoc 页面中使用该标签。
{% input placeholder="you@example.com" ariaLabel="Email" /%}属性的名称和取值与 React props 相同。
变体
“变体”部分每个 variant prop 可接受的取值。
| Prop | 取值 |
|---|---|
size | sm md lg |
结构
“结构”部分组件的组成部分,以及每个部分渲染的 data-refineui 角色。
| 部件 | 角色 |
|---|---|
root | input |
参考
“参考”部分- 设计指南和令牌细节见 RefineUI · Input。
- 通用规则见在 MDX 中使用和在 Markdoc 中使用。