Oddmash UI
所有组件

Input

输入单行文本。

用法

始终显示标签,并在提交前说明输入要求。

无障碍

用 htmlFor 和 id 关联标签,错误用 aria-invalid,提示用 aria-describedby。leadingIcon 用于装饰。传入 null 可隐藏动态图标并保持输入框焦点。

属性类型默认值
typeNative HTML input typetext
disabled / readOnlybooleanfalse
aria-invalidbooleanNone
leadingIconReactNodeNone
refHTMLInputElementNone
<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>

交互式文档