Labelauty jQuery Plugin
=========
A nice and lightweight jQuery plugin that gives beauty to checkboxes and
radio buttons and allows custom labels for each status of (un)checked inputs.
Demo: http://fntneves.github.io/jquery-labelauty
Note: Labelauty does not support Internet Explorer 7 and 8.
Installation
------------
You can choose to install labelauty with Bower :
~
bower install labelauty
~
Or with Yarn :
~
yarn add labelauty
~
Fast Usage
-----------
Write your checkbox or radio input in ~ html
~
~ js
$(document).ready(function(){
~
Simple, isn't it?
Aria Uses
----------
To add a Aria attributes, just add a aria-label. Labelauty will add tabindex, role and checked attributes.
~ html
~
Use Cases
----------
If you want to create user-friendly websites, this is the right choice!
Very useful in ~ html
~
~ js
$(document).ready(function(){
~
The data-labelauty attribute of radio and checkbox inputs lets you write custom labels for unchecked|checked cases.
Pipe character |, is the default separator between these two labels. You can change it (see Options section).
The data-labelauty attribute can be used in three different ways:
Unchecked|Checked
To choose a custom label for Unchecked and Checked states.
~ html
~
Message
Without separator, the Message text will be the permanent label. It means that label will not change between input state.
~ html
~
Omitted
By omitting this attribute, the default labels will be shown.
~ html
~
Options
-------------
Set a new ~ js
$(":checkbox").labelauty({ class: "myclass" });
~
When ~ js
$(":checkbox").labelauty({ label: false });
~
When ~ js
$(":checkbox").labelauty({ icon: false });
~
Change separator between custom labels, in data-labelauty attribute.
Choose your separator with ~ js
$(":checkbox").labelauty({ separator: "-" });
~
Do you want to generate random ID's for all inputs?
Change ~ js
$(":checkbox").labelauty({
~
Do you want custom default labels?
Set new text in ~ js
$(":checkbox").labelauty({
~
Actually, custom labels have different number of characters or width.
So, you can set ~ js
$(":checkbox").labelauty({ minimumwidth: "170px" });
~
If you dislike the previous option, then you can set labels with the same width.
Just set ~ js
$(":checkbox").labelauty({ samewidth: true });
~
Customization
-------------
You are free to customize all styles included in Labelauty jQuery Plugin.
Just edit jquery-labelauty.css to your liking and change images as you wish.
The included CSS file is tiny and simple. Don't be afraid to change it.
Acknowledgements
----------------
© 2013, Francisco Neves. Released under the MIT License.
Labelauty is authored and maintained by Francisco Nevesfrancisconeves.
Contributorsc can help to make this plugin better.
You can follow Trello of this repo.
My website (francisconeves.com)
Github (@fntneves)
Twitter (@fntneves)
body
section and call labelauty()
to beautify it.
Note: Call plugin when document is ready. See below:
$(":checkbox").labelauty();
});
remember me
checkboxes, in settings panel
, etc.
How does it work ?
--------------
The above case will generate one checkbox with default
labels "Checked" and "Unchecked", one for each input state.
You can change the default labels (see Options section) or
give custom labels to each checkbox, like the following example:
$(":checkbox").labelauty();
});
class
value that will be applied to changed inputs.
label
is set to false
, only the input icon appears and changes.
icon
is set to false
, only the input text label appears and changes.
separator
.
force_random_id
to true
.
force_random_id: true,
});
checked_label
and unchecked_label
.
checked_label: "You selected this",
unchecked_label: "You don't want it"
});
minimum-width
to custom CSS option.
same_width
to true
.