Label your form input like a boss with beautiful animation and without taking up space

Overview

#Label Better by Pete R. Label your form input like a boss with beautiful animation and without taking up space Created by Pete R., Founder of BucketListly

License: Attribution-ShareAlike 4.0 International

Demo

View demo

Compatibility

Modern browsers such as Chrome, Firefox, and Safari on both desktop and smartphones have been tested. I have not tested this on IE.

Basic Usage

jQuery Label Better will let you create a beautiful unobtrusive label for your form's input fields. The uniqueness about this plugin is that all you have to do is add a placeholder text, and we will show the label only when the user needs it.

To add this to your website, simply include the latest jQuery library together with jquery.label_better.js into your document's <head>, and simply call the function like this:

  $("input.label_better").label_better({
    position: "top", // This will let you define the position where the label will appear when the user clicked on the input fields. Acceptable options are "top", "bottom", "left" and "right". Default value is "top".
    animationTime: 500, // This will let you control the animation speed when the label appear. This option accepts value in milliseconds. The default value is 500.
    easing: "ease-in-out", // This option will let you define the CSS easing you would like to see animating the label. The option accepts all default CSS easing such as "linear", "ease" etc. Another extra option is you can use is "bounce". The default value is "ease-in-out".
    offset: 20, // You can add more spacing between the input and the label. This option accepts value in pixels (without the unit). The default value is 20.
    hidePlaceholderOnFocus: true // The default placeholder text will hide on focus
  });

Markups

With this plugin, you can use a markup to override the global options defined in the function above. Here are all the markups you can use to customize your experience to your liking:

data-position

This markup will let you define the position of each input field individually.

<input type="text" class="label_better" data-position="top" placeholder="Username">
<input type="text" class="label_better" data-position="right" placeholder="Email Address">

data-new-placeholder

There may be times when you want your placeholder text to be different from the label text. You can do that by defining the new placeholder text as follows and this value will be shown as the label instead.

<input type="text" class="label_better" data-new-placeholder="Type your username" placeholder="Username">
<input type="text" class="label_better" data-new-placeholder="Type your email address" placeholder="Email Address">

And that's all for Label Better plugin. Stay tuned for more updates.

If you want to see more of my plugins, visit The Pete Design, or follow me on Twitter and Github.

Other Resources

Comments
  • Opera keeps adding lb_label elements

    Opera keeps adding lb_label elements

    Opera (v12.16, OS X Mavericks) doesn't seem to be removing the added "lb_label" elements. The hover state is also not triggered correctly (could be a CSS bug).

    Attachment 1: Floating label is above cursor, but not above the field Attachment 2: Ever-stacking DOM elements

    screen shot 2014-01-21 at 14 31 31 screen shot 2014-01-21 at 14 31 44

    EDIT-------- looking into this .. currently looks like the oTransitionEnd isn't fired. Read here that it got renamed to "otransitionend", but that isn't working either.

    EDIT 2----- Got stuck at the point where it looks like the translate3D css isn't set. Logging the .attr('style) for the element after the switch/case went through, got me different results:

    Chrome: "opacity: 1; left: auto; right: auto; position: absolute; -webkit-transition: all 250ms cubic-bezier(0.175, 0.885, 0.42, 1.31); transition: all 250ms cubic-bezier(0.175, 0.885, 0.42, 1.31); top: 0px; -webkit-transform: translate3d(0, -24px, 0);"

    VS

    Opera: "left: auto; right: auto; position: absolute; top: 0px; opacity: 1;"

    EDIT 3----- Fixed the issue by changing the transition on translate3D to the good ol' "top". And if you're interested, I got this working in IE8-9 by adding the placeholder as :before content in browsers marked as old (with conditional comments).

    opened by flovan 0
  • Enhancing accessibility with label-elements

    Enhancing accessibility with label-elements

    The behaviour and animation of this solution is nice. However I am missing the use of actual label-elements. Pairing label- and input-elements is considered best practice for forms. Is there any reason for not using labels in the markup of the demo?

    opened by macbruker 0
  • Textarea & Fade

    Textarea & Fade

    Hi there! Great piece of code! Thank you for sharing.

    I have two quick questions.

    1. How can I apply this to a "textarea" input to a form? Tried several things and couldn't get it to work.
    2. The fade on animation happens for the label. How can the same be accomplished on the original placeholder?

    Cheers, Thomas

    opened by thomasgorczynski 0
  • Placeholder is removed when element is initiallized multiple times

    Placeholder is removed when element is initiallized multiple times

    Calling $.label_better on the same element multiple times with the hidePlaceholderOnFocus option removes the placeholder from the element.

    This is caused by initializing label_better multiple times on the same element.

    opened by cwohlman 0
  • No Label with Chrome Autocomplete

    No Label with Chrome Autocomplete

    When any input is autocompleted by Chrome on page load (i.e. login credentials), the label doesn't show up. The only way to get the label to show is to completely clear the input.

    opened by tariq86 0
  • Form reset does not clear bounced text

    Form reset does not clear bounced text

    I input something in a text and a label is shown on top of the text box. When I press Reset button (form reset) to clear the text box, the content is reset but the label still remains on top of the text box but also shows inside. Please instruct how to clear out the bounced text while doing form reset.

    Thanks :)

    opened by cardtwo 0
  • IE and textareas : in the middle of the box

    IE and textareas : in the middle of the box

    Hello! First great plugin, it runs really smooth.

    I just have one problem with IE and a textarea. For all my inputs, default position is "top" and the new placeholder goes where it should. But for my textarea, the new placeholder appears in the middle of the area.

    I attached a screenshot to give a better idea. screenshot

    Everything is ok with the other browsers.

    And here is my code. Everything should be default for label_better <textarea class="label_better orange" data-position="top" rows="8" name="histoire" data-new-placeholder="Ta meilleure histoire" placeholder="bla bla"></textarea> Thank you!

    opened by Fabrunet 0
Page switching like a Boss. Inspired by jQuery mobile

Roadcrew.js / Roadcrew.dart =========================== Roadcrew.js is a simple JavaScript snippet which allows "page transitions" like in jQuery mob

Christian Grobmeier 49 Aug 20, 2018
Input with floating label make with tailwindcss 3.0.18

tailwind-floating-label-input Input with floating label make with tailwindcss 3.0.18 Works with <input> and <textarea> elements. How to use <Input

Pablo David Gago Ballester 1 Feb 10, 2022
Quick and easy spring animation. Works with other animation libraries (gsap, animejs, framer motion, motion one, @okikio/animate, etc...) or the Web Animation API (WAAPI).

spring-easing NPM | Github | Docs | Licence Quick and easy spring animations. Works with other animation libraries (gsap, animejs, @okikio/animate, mo

Okiki Ojo 34 Dec 14, 2022
Auth-Form-Design - Beautiful Auth Form Designed using React 🥰.

?? Auth Form Design ?? Features 1. Check Your Password Strength 2. Can Use Suggested Password 3. Enjoy Responsive Design Getting Started with Create R

Samarpan Dasgupta 2 Dec 24, 2022
Bootstrap 5 Floating Label

@tkrotoff/bootstrap-floating-label Floating label for Bootstrap 5 Example: https://codesandbox.io/s/github/tkrotoff/bootstrap-floating-label/tree/code

Tanguy Krotoff 31 Dec 10, 2022
Tampermonkey script which adds the ability to add a user-defined label/tag/flair on a user, shown throughout Hacker News.

Hacker News User Tags Hacker News User Tags is a Tampermonkey userscript which allows the user to associate a custom coloured label/tag on usernames t

Lachlan McDonald 2 Oct 7, 2022
A web application for a company that provides commercial and scientific space travel services. The application will allow users to book rockets and join selected space missions.

Space Travelers A web application for a company that provides commercial and scientific space travel services. The application will allow users to boo

Hector Torres 2 Apr 6, 2022
This web application provides commercial and scientific space travel services. The application allows users to book rockets and join selected space missions.

space-hub About Project "Space Traveler's Hub" is A web application that provides commercial and scientific space travelling services, We are working

Nicholas Emmanuel 7 Nov 2, 2022
This a web application for a company that provides commercial and scientific space travel services. The application will allow users to book rockets, dragons and join selected space missions.

Space Travelers' Hub In this project, we have worked with the real live data from the SpaceX API. Our task was to build a web application for a compan

Apuabi Titilope 4 Oct 31, 2022
In this project we built a web application that consumes an SpaceX API. It provides commercial and scientific space travel services that allows users to book rockets and join selected space missions.

Space Travelers' Hub In this project we built a web application that consumes an SpaceX API. It provides commercial and scientific space travel servic

Diego Yon 7 Sep 30, 2022
This web application provides commercial and scientific space travel services. The application allows users to book rockets and join selected space missions.

Space Traveler's Hub This web application provides commercial and scientific space travel services. The application allows users to book rockets and j

Michael Mesfin 6 Oct 4, 2022
Space Travelers' Hub - a web application that facilitates booking rockets and join selected space missions

This is a web application that facilitates booking rockets and join selected space missions. It is built for a company that offers both commercial and scientific space travel services. The application also works with real live data from the SpaceX API.

Mong'are 6 Mar 29, 2022
"Space-Travelers-Hub" is a website that allows users to book rockets and join selected space missions by using data from the SpaceX API.

Space-Travelers-Hub This project was bootstrapped with Create React App. Description "Space-Travelers-Hub" is a website that allows users to book rock

Tresor Sawasawa 4 Mar 13, 2022
Welcome to Space Traveler's HUB, this web app allows the user to take a fictional tour across the space.

Welcome to Space Traveler's HUB, this web app allows the user to take a fictional tour across the space. The user can choose a rocket from our catalog interface, and reserve it. Also, the user can see recent special missions and join them. Finally, the user will be able to keep track of all your rockets and mission they are subscribed to. Build with React, Redux, React-router, and Railwindcss.

Mihreteab Misganaw 3 Jan 27, 2022
I made countdown birthday and fireworks animation using HTML Canvas, CSS, JS. The fireworks animation gonna come out once the countdown is finished or in other words, "Birthday Time".

Countdown-Birthday-Fireworks-Animation I made countdown birthday and fireworks animation using HTML Canvas, CSS, JS. The fireworks animation gonna com

Mahardika Bayu S.B 19 Dec 31, 2022
Animation library build on top of web animation API (WAAPI)

unanime.js Javascript animation library build on top of web animation API (WAAPI). Learn more about WAAPI: Web animation API Documentation Blog Daniel

Clément Laval 3 Jun 21, 2022
A JavaScript animation plugin for menus. It creates a div that moves when you mouse over an element, giving it an elastic animation.

Lava-Lamp Description: A JavaScript animation plugin for menus. It creates a div that moves when you mouse over an element, giving it an elastic anima

Richard Hung 38 Jun 4, 2022