- Customizable through CSS. Changes animations, styles, etc.
- Accessible (uses a label element).
- Doesn't require that you change your layout. The labels slide above all other content.
- Easy to read the labels even when the input is focused.
If you are using Rails, check out sky-labels-rails. Otherwise, read the following.
- Download JavaScript & CSS files. Get them from /dist/sky-labels.min.js and /dist/sky-labels.css.
- Put JavaScript & CSS files in your CSS and JavaScript directories.
- Link to the JavaScript in your
<head>
tag or near the end of the<body>
tag. Be sure to addsky-labels.min.js
below jQuery. - Wrap inputs & labels in a
<section>
,<div>
or other block level element with the classsky-label
. Be sure the label has afor
that matches the input. - Call
setupSkyLabels()
during thedomready
event or right after you include thesky-labels.min.js
. - Customize the CSS to your liking! You can change how it animates, colors, size, etc.
<!-- Put the stylesheet in the <head> -->
<link rel="stylesheet" type="text/css" href="css/sky-labels.css">
<!-- In your <head> or just before the </body> tag -->
<script src="js/sky-labels.js"></script>
<!-- Setup events for slide labels -->
<script type="text/javascript">
setupSkyLabels();
</script>
<!-- Wrap the input and label in a block element with the class "sky-label" -->
<section class="sky-label">
<!-- Be sure the for matches the input so that when the label is clicked the
input is focused -->
<label for="first-name">First name</label>
<input name="first-name" id="first-name" type="text">
</section>
Check out the example HTML from the SkyLabels.js website
SkyLabels.js adds and removes styles from the element with the class
sky-label
so that you can customize every step of the slide.
The class are applied as follows
sky-label-focused
when the input has been focusedsky-label-has-text
when the input has text
You can apply styles and animations based on these two classes. See the example CSS from the SkyLabels.js website.
You need node. Then, in your shell:
git clone https://github.com/thoughtbot/sky-labels.git
cd sky-labels
npm install -g grunt-cli
npm install
grunt # This compiles and minifies the JavaScript and Sass into dist/
Sky Labels uses Jasmine for testing. Add new specs to the spec
folder.
To run tests: open spec/runner.html