![]() |
VOOZH | about |
Bootstrap 5 floating labels are form labels that float over input fields, improving UX. Wrap form controls like <input>, <label>, <textarea>, <select> inside <div> with class .form-floating. Ensure these elements precede <label> inside the floating <div>.
Bootstrap 5 Floating labels:
| Component | Description |
|---|---|
| Textareas | Use CSS height property for Floating label Textarea, adjusting height similar to the input. |
| Selects | Utilize Floating labels Component Selects for input fields with floating labels. |
| Layout | Employ Floating labels Layout within a grid system, placing form elements within column classes. |
| Sass | Customize Floating labels by adjusting default values in Bootstrap 5 SCSS files for tailored usage. |
Syntax:
<div class="form-floating"> ...</div>Example 1: In this example, <input>, <textarea>, and <label> elements are wrapped inside <div> element with .form-floating class.
Output:
Example 2: In this example, <select> and <label> elements are wrapped inside <div> element with .form-floating class.
Output: