]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Docs: enhance floating labels `placeholder` usage description (#41526)
authorJulien Déramond <juderamond@gmail.com>
Mon, 9 Jun 2025 11:57:57 +0000 (13:57 +0200)
committerGitHub <noreply@github.com>
Mon, 9 Jun 2025 11:57:57 +0000 (13:57 +0200)
site/src/content/docs/forms/floating-labels.mdx

index 642ee8cb1f8ce27d40be094ec48ea699b43aaeaa..dd2db0813e1233844b64eae0d2a5c2edd7d355ef 100644 (file)
@@ -6,7 +6,11 @@ toc: true
 
 ## Example
 
-Wrap a pair of `<input class="form-control">` and `<label>` elements in `.form-floating` to enable floating labels with Bootstrap’s textual form fields. A `placeholder` is required on each `<input>` as our method of CSS-only floating labels uses the `:placeholder-shown` pseudo-element. Also note that the `<input>` must come first so we can utilize a sibling selector (i.e., `~`).
+Wrap a pair of `<input class="form-control">` and `<label>` elements in `.form-floating` to enable floating labels with Bootstrap’s textual form fields.
+
+A non-empty `placeholder` attribute is required on each `<input>` as our CSS-only floating label implementation relies on the `:placeholder-shown` pseudo-element to detect when the input is empty. The placeholder text itself is not visible; only the `<label>` is shown to users.
+
+Also note that the `<input>` must come first so we can utilize a sibling selector (i.e., `~`).
 
 <Example code={`<div class="form-floating mb-3">
     <input type="email" class="form-control" id="floatingInput" placeholder="name@example.com">