- 🇫🇷France lazzyvn paris
use field group and field group bootstrap → you will have floating label
- Status changed to Closed: won't fix
almost 2 years ago 9:34am 11 February 2023 - 🇦🇺Australia VladimirAus Brisbane, Australia
Thanks everyone for contribution. 🍻
Obviously the issue can be solved without modifying the theme.
Closing... - 🇩🇰Denmark ressa Copenhagen
I got floating labels in my subtheme with these steps:
- Copy the input.html.twig file from /bootstrap5/templates/form to templates/form folder in my sub-theme
- Tweak this part, from:
<input{{ attributes }} />
To:<div class="form-floating"> <input{{ attributes }} /> <label for="{{ attributes.id }}">{{ attributes.placeholder }}</label> </div>
I got the
id
's to match andplaceholder
, by setting them in my custom form:$form['age'] = [ '#type' => 'number', '#title' => $this->t('Age'), '#placeholder' => 'Years old', '#attributes' => [ 'class' => ['age'], 'id' => ['age'], ], '#required' => TRUE, ];