Advertising sustains the DA. Ads are hidden for members. Join today

Webform Cookbook

No Code Implementation of Bootstrap Floating Labels

Last updated on
30 November 2021

This page has not yet been reviewed by Webform Cookbook maintainer(s) and added to the menu.

Instead appearing above a before a field, Floating Labels appear in a form field like placeholder text. When a user clicks the field, the label moves to the top of the field and the text size is reduced. There are several UX and accessibility experts who dislike this design pattern, but you see floating labels used in at least the login form of many popular services. If you decide to you want to implement Bootstrap 5's floating labels, here's a "no code" method for configuring Webform fields with floating labels.

  1. Configure the Title display (label) to display after the input
  2. Add text to Placeholder. In this case we're using Last Name

    Screenshot of Webform configuration form described in steps 1 and 2
     

  3. Add a custom class of form-floating to Wrapper in the Advanced options
  4. Add a custom class of form-control to the Element in the Advanced options

    Screenshot of Webform configuration form describe in steps 3 and 4

That's it. As long as the theme is using Bootstrap 5, the form will render with the Placeholder text in the field and then update to show Last Name at the top of the field once selected.

Webform with Floating Label configured on First Name, Last Name, Email and Phone fieldsWebform with Floating Label configured and Last Name selected

Help improve this page

Page status: No known problems

You can: