Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

anyblades/float-label-css

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

91 Commits
91 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🥷 Classless CSS-only Float Label. Finally.

Bulletproof classless CSS-only implementation of Float Label pattern with automatic fallback for ANY non-supporting browser.

Examples:


Killer features

  • No JS — pure CSS
  • No hacks with required and :valid
    ↳ HTML5 validation support
  • Compatible with <select> and <textarea> fields
  • No need to define for="..." attribute on <label>
  • NEW in v2: Finally, the text label can be placed BEFORE the input field!
  • NEW in v2: Class-less!

Install

Via CDN
<link rel="stylesheet" href="
  https://cdn.jsdelivr.net/npm/@anyblades/blades@0/assets/float-label.min.css
">
Via npm
npm install @anyblades/blades

Then in your .css:

@import "@anyblades/blades/float-label";
Included with

Usage

Simply place <input> inside <label> to enable float label:

<label>
  <span>Email</span>
  <input type="email" placeholder="email@example.com" />
</label>

NOTE: W3C allows this!


Alternatively wrap <label> and <input> inside .has-float-label:

<div class="has-float-label">
  <label for="email">Email</label>
  <input id="email" type="email" placeholder="email@example.com" />
</div>

NOTE: for="..." attribute is required on <label> in this case


Credits


Browser support

Any browser with https://caniuse.com/css-placeholder-shown, https://caniuse.com/css-has and https://caniuse.com/css-nesting.

All non-supporting browsers should gracefully fall-back to the default layout.

=> Can be used in ANY browser as is!


Featured by:


About

Bulletproof classless CSS-only implementation of Float Label pattern with automatic fallback for ANY non-supporting browser 🥷

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Morty Proxy This is a proxified and sanitized view of the page, visit original site.