Forms

Floating labels

Animated labels that float above the input when focused or filled.

Placeholder requirement

Floating labels require placeholder=" " (a single space) on the input. This triggers the CSS :not(:placeholder-shown) selector used to detect when the field has content.

Basic floating label

Wrap an .bima-input and its <label> in a .bima-float container. The label must come after the input in the HTML.

<!-- IMPORTANT: placeholder=" " (space) is required -->
<!-- Label must come AFTER the input -->

<div class="bima-float">
  <input type="text" id="name" class="bima-input" placeholder=" ">
  <label for="name">Full name</label>
</div>

<div class="bima-float">
  <input type="email" id="email" class="bima-input" placeholder=" ">
  <label for="email">Email address</label>
</div>

Pre-filled value

When a field has an existing value, the label automatically floats above without needing focus.

<!-- Label floats automatically when value is present -->
<div class="bima-float">
  <input type="text" id="name" class="bima-input" placeholder=" " value="Ahmad Bin Rashid">
  <label for="name">Full name</label>
</div>

Floating label with textarea

Floating labels work with .bima-textarea as well.

<div class="bima-float">
  <textarea id="message" class="bima-textarea" rows="4" placeholder=" "></textarea>
  <label for="message">Your message</label>
</div>

Floating label with select

Floating labels also work with .bima-select.

<div class="bima-float">
  <select id="country" class="bima-select" data-bima-select>
    <option value="" label=" "></option>
    <option value="gh">Ghana</option>
    <option value="ke">Kenya</option>
  </select>
  <label for="country">Country</label>
</div>

Disabled floating label

<div class="bima-float">
  <input type="text" id="policy-id" class="bima-input" placeholder=" " value="POL-2024-001" disabled>
  <label for="policy-id">Policy ID</label>
</div>