Input
输入单行文本。
用法
始终显示标签,并在提交前说明输入要求。
无障碍
用 htmlFor 和 id 关联标签,错误用 aria-invalid,提示用 aria-describedby。leadingIcon 用于装饰。传入 null 可隐藏动态图标并保持输入框焦点。
| 属性 | 类型 | 默认值 |
|---|---|---|
| type | Native HTML input type | text |
| disabled / readOnly | boolean | false |
| aria-invalid | boolean | None |
| leadingIcon | ReactNode | None |
| ref | HTMLInputElement | None |
<label htmlFor="project">Project name</label>
<Input id="project" placeholder="Your next idea"
aria-describedby="project-hint"
leadingIcon={
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinejoin="round">
<path d="M3 6h6l2 2h10v11H3z" />
</svg>
} />
<p id="project-hint">Use a short, memorable name.</p>