• Stars
    star
    129
  • Rank 270,496 (Top 6 %)
  • Language
    CSS
  • Created about 10 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Float label pattern built with pure SCSS

Adaptive Placeholders

Adaptive placeholders is a Sass mixin for an interactive form placeholder initially made by Danny King.

This Sass mixin comes with additional settings to help you easily configure the placeholder to match your design.

Note: I no longer maintain this repository.

Screenshot

Adaptive Placeholder works with both text input fields and textarea.

Adaptive Placeholders Input Demo Adaptive Placeholders Textarea Demo

Requirements

  • Sass v3.3 and above
  • You have Normalize.css in the project

Installation

Download the project either by downloading the zip, or using Bower

$ bower install adaptive-placeholders

Usage

Add Adaptive Placeholders into your project and import it into your main stylesheet with

@import "pathToAdaptivePlaceholders/adaptive-placeholders"; 

Write your HTML in this way:

<form action="#">
    <!-- input must have an required attribute -->
    <input type="text" name="input" id="input" required>
    <!-- labels must have placeholder and alt attributes -->
    <label for="input" placeholder="First Placeholder Label" alt="Second Placeholder Label"></label>
</form>

Then call the mixin.

input {
    @include adaptive-placeholder();
}

Customizing Adaptive Placeholder.

Adaptive placeholder comes with a set of defaults ready to use.

$adaptive-placeholder: (
  height: 3em,
  margin: 1em,
  border: 1px,
  border-radius: 1.5em,
  font-size: 1em,
  border-color: #cccccc,
  label-color: #999999,
  active-color: #e87e22,
  valid-color: #23a045,
  placeholder-background-color: white,
  textarea: false
  );

You can create your own settings for adaptive-placeholder by creating a Sass map named $adaptive-placeholder. Any defaults not overwritten will be added to the Sass map.

// Defining new defaults
$adaptive-placeholder: (
    height: 4em; 
)

// Calling Adaptive placeholders
input {
    @include adaptive-placeholder(); 
}

The adaptive placeholders provides you with a optional argument to insert a sass map if you would like to keep the defaults intact, or would like to include a second style.

input {
    @include adaptive-placeholder($optional-map); 
}

Working with Textareas

Textareas are styled differently from inputs items. To use adaptive placeholders with textareas, write your html the same way as you would use adaptive placeholders for input.

<form action="">
    <textarea name="textarea" id="textarea" required></textarea>
    <label for="textarea" placeholder="First Textarea Placeholder" alt="Second Textarea Placeholder"></label>
</form>

Create a new sass map for textareas and call it. Make sure textarea is set to true in the sass map.

$textarea-placeholder : (
    height: 18em, 
    border-radius: 6px,
    textarea: true, 
)
// Call textarea placeholder 
textarea {
    @include adaptive-placeholder($textarea-placeholder); 
}

Alternatively, you can insert the sass map directly into the mixin.

// Call textarea placeholder 
textarea {
    @include adaptive-placeholder((height: 18em, border-radius: 6px, textarea:true)); 
}

Browser Tests

Works on IE10+, Firefox 28+, Chrome 31+, Safari 7+, Opera 22+

Changelog

1.1.4
  • Remove Normalize.scss import statement
1.1.0
  • Fix translateY bug with calc for IE 10.
  • Tested and proved to work with IE 10 & IE 11
  • Reworked bower file structure
  • Placed demo into app folder
1.0.1:
  • Added browser prefixes for all transitions and transformations used in Adaptive Placeholders

Credits

@ Danny King for the concept and initial code. The original Less code can be found here

License

MIT License.

More Repositories

1

typi

A sass mixin to make responsive typography easy
CSS
860
star
2

gulp-starter-csstricks

Gulp starter for CSS Tricks article
JavaScript
393
star
3

mappy-breakpoints

Breakpoints with Maps in Sass
SCSS
384
star
4

zellwk.com

Github repo for https://zellwk.com
MDX
348
star
5

zl-fetch

A library that makes the Fetch API a breeze
JavaScript
276
star
6

crud-express-mongo

Repo for Zell's CRUD, Express and Mongo tutorial
JavaScript
176
star
7

dotfiles

Shell
170
star
8

crud-demo

Source code for "Building a CRUD app with Node, Express, and MongoDB tutorial"
JavaScript
165
star
9

javascript

A collection of useful JavaScript snippets curated by Zell
JavaScript
159
star
10

css-reset

Zell's personal CSS Reset
CSS
149
star
11

endpoint-testing-example

JavaScript
47
star
12

gulp-susy-starter

Susy Starter that uses LibSass with Gulp
CSS
39
star
13

themify

Sass Mixin to create multiple themes easily
CSS
34
star
14

vertical-rhythms-without-compass

CSS
18
star
15

ama

A repository where you can ask anything and Zell will answer.
9
star
16

source-for-automating-workflow-book

JavaScript
9
star
17

build-and-deploy-workshop

Astro
9
star
18

grunt-susy-starter

Susy Starter that uses LibSass with Grunt
CSS
8
star
19

devfest

github repo for the devfest.asia 2015
JavaScript
7
star
20

Learnjavascript-api

API for Learn JavaScript
JavaScript
6
star
21

convertkit-cli

A Simple CLI for Convertkit
JavaScript
6
star
22

CSSConf.Asia-animating-svg

JavaScript
6
star
23

demos

JavaScript
5
star
24

responsive-typography-slides

JavaScript
5
star
25

responsive-css-components-slides

JavaScript
5
star
26

devfest-2016

CSS
4
star
27

webpack-starter

Webpack starter (without React)
JavaScript
4
star
28

better-share-buttons

CSS
4
star
29

buffalo

Simple Blog site generator
JavaScript
4
star
30

Learning-Susy

The walkthrough codes for Learning Susy
CSS
3
star
31

simple-workflow

HTML
3
star
32

responsive-typography-workshop

CSS
3
star
33

FEWD

HTML
3
star
34

basic-susy-starter

A very simple Susy Starter that uses the terminal to compile Sass into CSS
CSS
3
star
35

learngit.io

Website for learngit.io
HTML
3
star
36

ava-mdb-test

JavaScript
2
star
37

Dojo-Playground

Astro
2
star
38

countdown

A simple countdown timer to a specific date (with timezone support)
JavaScript
2
star
39

shuffle-and-split

Shuffles and splits and array into equal groups
JavaScript
2
star
40

chatapp-polymer

Chatapp built with Polymer
HTML
2
star
41

simple-susy-starter

For easy Susy related layouts / tests
CSS
2
star
42

susy-helpers

Helpers for Susy
CSS
2
star
43

scalable-components

JavaScript
2
star
44

publishing-to-npm

An example repository to teach people how to publish to npm
2
star
45

resize-images

Resizes images. Suitable for use directly in Node, or with a Gulp workflow
JavaScript
2
star
46

build-and-deploy-workshop-sanity

JavaScript
1
star
47

ayw

Website for AYW
Nunjucks
1
star
48

roam-css

CSS
1
star
49

cssnano-issue

JavaScript
1
star
50

devops

1
star
51

slides-scaling-components-cn

Slides for CSSConf China #4
JavaScript
1
star
52

compass-susy-starter

A very simple Susy Starter that uses Compass to compile Sass into CSS
CSS
1
star
53

jsroadmap.com

SCSS
1
star
54

zellwk-pdf-maker

Helps to make PDFs for https://zellwk.com
JavaScript
1
star
55

github-actions-tutorial

1
star
56

count-to-date

A simple countdown timer to a specific date
JavaScript
1
star
57

cohort19x

CSS
1
star
58

window-sizer

Small helper to make debugging responsive websites easier
JavaScript
1
star