Basic Input
A labelled text input with helper text wired to it via aria-describedby.
6 個のフレームワーク初級
A label that sits inside the field and floats above the value on focus or fill.
<!--
The trick that makes this work without a line of JavaScript: the input carries
placeholder=" " - a single space, never empty. :placeholder-shown then means
exactly "the user has typed nothing", and the label parks itself over the box
in that state and floats up otherwise.
This is still a real <label for>, not a placeholder cosplaying as one. It is
in the accessibility tree the whole time; it only moves.
-->
<div class="float-field">
<input
class="float-field__input"
id="float-field-name"
name="fullName"
type="text"
placeholder=" "
autocomplete="name"
/>
<label class="float-field__label" for="float-field-name">Full name</label>
</div>| Prop | 型 | デフォルト | 説明 |
|---|---|---|---|
label必須 | string | - | 読み込み中に読み上げられるアクセシブルなラベル。 |
value | string | - | 指標の現在値。フォーマット済みの文字列を渡します。 |
disabled | boolean | false | 操作を無効にし、コントロールを淡色表示にします。 |
className | string | - | ルート要素にマージされる追加クラス。 |
`placeholder=" "` - a single space, never empty - is load-bearing. It makes `:placeholder-shown` mean exactly "the user has typed nothing", which is what drives the float, and it is why the TypeScript variant omits `placeholder` from the inherited attributes: a caller-supplied one would silently pin the label in its floated position forever. This is still a real `<label for>` that lives in the accessibility tree the whole time; it only moves. `pointer-events-none` lets clicks pass through to the input underneath, and the asymmetric `pt-5` reserves the strip the label lands in so the value never shares a row with it.