Forms
Floating labels
The label sits inside the field like a placeholder, then moves up out of the way when you type — so it's compact, but people never lose track of what a field is for.
<div class="form-floating">
<input class="form-control" id="email" type="email">
<label for="email">Email address</label>
</div>
- Put the
<label>after the field, and link them withfor/id. - No placeholder needed — Moey adds an invisible one. If you do give a placeholder, it shows as a hint once the field has focus (try the phone number below).
- Required fields get a
*automatically.
Hints, dropdowns and textareas
A .form-select is a normal Moey dropdown. While it still shows its "Choose…" option the label rests inside; once something is picked the label moves up.
<div class="form-floating">
<input class="form-control" id="phone" type="tel" placeholder="+351 912 345 678">
<label for="phone">Phone</label>
</div>
<div class="form-floating">
<select class="form-select" id="country">
<option value="" disabled selected>Choose…</option>
<option>Portugal</option><option>Spain</option>
</select>
<label for="country">Country</label>
</div>
<div class="form-floating">
<textarea class="form-control" id="note" rows="3"></textarea>
<label for="note">Note for the courier</label>
</div>
A whole form
Floating labels shine in short forms like sign-in, sign-up and checkout.
<form class="form-filled">
<div class="form-floating">
<input class="form-control" id="first" autocomplete="given-name" required>
<label for="first">First name</label>
</div>
…
</form>
With icons and buttons
Combine with Form adorn for icons and buttons inside the field, or put a floating field in an input group.
$
<div class="form-floating form-adorn">
<i class="mi mi-lock adorn-start"></i>
<input class="form-control" id="password" type="password">
<label for="password">Password</label>
<button type="button" class="btn btn-ghost btn-icon btn-sm adorn-end" aria-label="Show password">…</button>
</div>
<div class="input-group">
<span class="input-group-text">$</span>
<div class="form-floating">
<input class="form-control" id="amount" type="number">
<label for="amount">Amount</label>
</div>
<button class="btn btn-default" type="button">Send</button>
</div>
Validation and states
In a .field, errors work as usual and the label turns red too — type something that isn't an email and click away.
Enter a full email address, like ana@moey.test.
<div class="field">
<div class="form-floating">
<input class="form-control" id="work-email" type="email" required>
<label for="work-email">Work email</label>
</div>
<div class="form-error">Enter a full email address, like ana@moey.test.</div>
</div>
| Class | What it does |
|---|---|
.form-floating | Wraps a .form-control or .form-select and its <label> (label last) |
.form-floating.form-adorn | Floating label plus icons / buttons inside the field |
.input-group > .form-floating | A floating field as one piece of an input group |
.form-filled | Borderless, filled look — on the field or any parent |
--mo-floating-height | The field's height (default 3.25rem / 52px) |