Socket
Socket
Sign inDemoInstall

@material/floating-label

Package Overview
Dependencies
3
Maintainers
11
Versions
1664
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @material/floating-label

The Material Components for the web floating-label component


Version published
Weekly downloads
854K
decreased by-14.75%
Maintainers
11
Install size
181 kB
Created
Weekly downloads
 

Readme

Source

Floating Label

Floating labels display the type of input a field requires. Every text field and select should have a label. Labels are aligned with the input line and always visible. They can be resting (when a field is inactive and empty) or floating. The label is a text caption or description for the text field.

Design & API Documentation

  • Material Design guidelines: Text Fields Layout

Usage

HTML Structure

<label class="mdc-floating-label" for="my-text-field-id">Hint text</label>

Usage within mdc-text-field

<div class="mdc-text-field">
  <input type="text" id="my-text-field-id" class="mdc-text-field__input">
  <label class="mdc-floating-label" for="my-text-field-id">Hint text</label>
  <div class="mdc-text-field__bottom-line"></div>
</div>
Avoid Dynamic ID Generation

If you're using the JavaScript-enabled version of floating label, you can avoid needing to assign a unique id to each <input> by wrapping mdc-text-field__input within a <label>:

<label class="mdc-text-field">
  <input type="text" class="mdc-text-field__input">
  <span class="mdc-floating-label">Hint Text</span>
  <div class="mdc-text-field__bottom-line"></div>
</label>

CSS Classes

CSS ClassDescription
mdc-floating-labelMandatory.
mdc-floating-label--float-aboveIndicates the label is floating above the text field.
mdc-floating-label--shakeShakes the label.

SCSS Mixins

MixinDescription
mdc-floating-label-ink-color($color)Customizes the ink color of the label.
mdc-floating-label-fill-color($color)Customizes the fill color of the label.
mdc-floating-label-shake-keyframes($modifier, $positionY, $positionX, $scale)Generates a CSS @keyframes at-rule for an invalid label shake. Used in conjunction with the mdc-floating-label-shake-animation mixin.
mdc-floating-label-shake-animation($modifier)Applies shake keyframe animation to label.
mdc-floating-label-float-position($positionY, $positionX, $scale)Sets position of label when floating.

MDCFloatingLabel

Method SignatureDescription
shake(shouldShake: boolean) => voidShakes or stops shaking the label, depending on the value of shouldShake. Proxies to the foundation method of the same name.
float(shouldFloat: boolean) => voidFloats or docks the label, depending on the value of shouldFloat. Proxies to the foundation method of the same name.
getWidth() => numberReturns the width of the label element.

MDCFloatingLabelAdapter

Method SignatureDescription
addClass(className: string) => voidAdds a class to the label element.
removeClass(className: string) => voidRemoves a class from the label element.
getWidth() => numberReturns the width of the label element.

MDCFloatingLabelFoundation

Method SignatureDescription
shake(shouldShake: boolean)Shakes or stops shaking the label, depending on the value of shouldShake.
float(shouldFloat: boolean)Floats or docks the label, depending on the value of shouldFloat.
getWidth() => numberReturns the width of the label element.

Keywords

FAQs

Last updated on 05 Mar 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc