Skip to content

Commit c8a4d4e

Browse files
Docs: enhance floating labels placeholder usage description
1 parent 0a9fa30 commit c8a4d4e

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

site/src/content/docs/forms/floating-labels.mdx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ toc: true
66

77
## Example
88

9-
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., `~`).
9+
Wrap a pair of `<input class="form-control">` and `<label>` elements in `.form-floating` to enable floating labels with Bootstrap’s textual form fields.
10+
11+
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.
12+
13+
Also note that the `<input>` must come first so we can utilize a sibling selector (i.e., `~`).
1014

1115
<Example code={`<div class="form-floating mb-3">
1216
<input type="email" class="form-control" id="floatingInput" placeholder="name@example.com">
@@ -49,7 +53,7 @@ To set a custom height on your `<textarea>`, do not use the `rows` attribute. In
4953

5054
## Selects
5155

52-
Other than `.form-control`, floating labels are only available on `.form-select`s. They work in the same way, but unlike `<input>`s, theyll always show the `<label>` in its floated state. **Selects with `size` and `multiple` are not supported.**
56+
Other than `.form-control`, floating labels are only available on `.form-select`s. They work in the same way, but unlike `<input>`s, they'll always show the `<label>` in its floated state. **Selects with `size` and `multiple` are not supported.**
5357

5458
<Example code={`<div class="form-floating">
5559
<select class="form-select" id="floatingSelect" aria-label="Floating label select example">

0 commit comments

Comments
 (0)