Input with Icon
A search field with a leading icon and a clear button that appears once filled.
6 個のフレームワーク中級
A labelled text input with helper text wired to it via aria-describedby.
<!--
The three parts of a text field, in the order a screen reader meets them:
the label names it, the input is it, and the helper text explains it. The
helper is wired with aria-describedby rather than left floating next to the
box - otherwise it is announced to nobody, which is the one audience that
cannot see it sitting there.
-->
<div class="field">
<label class="field__label" for="field-email">Email address</label>
<input
class="field__input"
id="field-email"
name="email"
type="email"
autocomplete="email"
placeholder="you@example.com"
aria-describedby="field-email-help"
/>
<p class="field__help" id="field-email-help">We only use this to send receipts.</p>
</div>| Prop | 型 | デフォルト | 説明 |
|---|---|---|---|
label必須 | string | - | 読み込み中に読み上げられるアクセシブルなラベル。 |
value | string | - | 指標の現在値。フォーマット済みの文字列を渡します。 |
disabled | boolean | false | 操作を無効にし、コントロールを淡色表示にします。 |
className | string | - | ルート要素にマージされる追加クラス。 |
The three parts are not decoration - the label names the field, the input is the field, and the helper explains it. The helper is linked with `aria-describedby` rather than left floating beside the box; unlinked, it is announced to nobody, which is the one audience that cannot see it sitting there. The TypeScript variant omits `id` from the inherited attributes and generates one with `useId`, so the label and the input cannot be wired to different ids - the most common way a "labelled" field turns out not to be. Note `placeholder-gray-500` lightens to `gray-400` in dark: keeping the same grey would drop it to 4.0:1 and fail AA.