input-placeholder
v0.0.1
Published
This library is meant to help get around the limitation that placeholder font size can not be larger than the input font size. Instead of using a placeholder, the library will help align/hide/show a label to act as a placeholder.
Downloads
3
Maintainers
Readme
Input Placeholder
Purpose
This library tries to help solve the problem that an input placeholder font size can not be larger than the font size of the input element, otherwise the placeholder will be truncated vertically. Check out this Stack Overflow for a more complete idea of the problem.
How does this library help?
Instead of using the the standard placeholder attribute, this library helps use another HTML element, most likely a label as a placeholder. This library does not style the label at all, future support may be added in the future, instead it hide / shows the placeholder when appropriate.
How to use
Plain JS
- Load this library via a script tag or use a module bundler.
- Add the class label-placeholder to the input element you are targeting.
- Ensure that the label for attribute matches the id attribute of the input.
- Once the DOM is ready run
new InputPlaceholderHandler.InputPlaceholderHandler.initialize();
Typescript
- Import the library
import InputPlaceholderHandler from 'InputPlaceholderHandler';
- Add the class label-placeholder to the input element you are targeting.
- Ensure that the label for attribute matches the id attribute of the input.
- Once the DOM is ready run
new InputPlaceholderHandler().initialize();