@material/floating-label

  • Version 14.0.0
  • Published
  • 220 kB
  • 8 dependencies
  • MIT license

Install

npm i @material/floating-label
yarn add @material/floating-label
pnpm add @material/floating-label

Overview

The Material Components for the web floating-label component

Index

Variables

variable cssClasses

const cssClasses: {
LABEL_FLOAT_ABOVE: string;
LABEL_REQUIRED: string;
LABEL_SHAKE: string;
ROOT: string;
};
  • Copyright 2016 Google Inc.

    Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Classes

class MDCFloatingLabel

class MDCFloatingLabel extends MDCComponent<MDCFloatingLabelFoundation> {}

    method attachTo

    static attachTo: (root: Element) => MDCFloatingLabel;

      method float

      float: (shouldFloat: boolean) => void;
      • Styles the label to float/dock.

        Parameter shouldFloat

        If true, floats the label by adding a CSS class; otherwise, docks it by removing the class.

      method getDefaultFoundation

      getDefaultFoundation: () => MDCFloatingLabelFoundation;

        method getWidth

        getWidth: () => number;

          method setRequired

          setRequired: (isRequired: boolean) => void;
          • Styles the label as required.

            Parameter isRequired

            If true, adds an asterisk to the label, indicating that it is required.

          method shake

          shake: (shouldShake: boolean) => void;
          • Styles the label to produce the label shake for errors.

            Parameter shouldShake

            If true, shakes the label by adding a CSS class; otherwise, stops shaking by removing the class.

          class MDCFloatingLabelFoundation

          class MDCFloatingLabelFoundation extends MDCFoundation<MDCFloatingLabelAdapter> {}

            constructor

            constructor(adapter?: Partial<MDCFloatingLabelAdapter>);

              property cssClasses

              static readonly cssClasses: {
              LABEL_FLOAT_ABOVE: string;
              LABEL_REQUIRED: string;
              LABEL_SHAKE: string;
              ROOT: string;
              };

                property defaultAdapter

                static readonly defaultAdapter: MDCFloatingLabelAdapter;

                method destroy

                destroy: () => void;

                  method float

                  float: (shouldFloat: boolean) => void;
                  • Styles the label to float or dock.

                    Parameter shouldFloat

                    If true, adds the float CSS class; otherwise, removes float and shake classes to dock the label.

                  method getWidth

                  getWidth: () => number;
                  • Returns the width of the label element.

                  method init

                  init: () => void;

                    method setRequired

                    setRequired: (isRequired: boolean) => void;
                    • Styles the label as required.

                      Parameter isRequired

                      If true, adds an asterisk to the label, indicating that it is required.

                    method shake

                    shake: (shouldShake: boolean) => void;
                    • Styles the label to produce a shake animation to indicate an error.

                      Parameter shouldShake

                      If true, adds the shake CSS class; otherwise, removes shake class.

                    Interfaces

                    interface MDCFloatingLabelAdapter

                    interface MDCFloatingLabelAdapter {}
                    • Defines the shape of the adapter expected by the foundation. Implement this adapter for your framework of choice to delegate updates to the component in your framework of choice. See architecture documentation for more details. https://github.com/material-components/material-components-web/blob/master/docs/code/architecture.md

                    method addClass

                    addClass: (className: string) => void;
                    • Adds a class to the label element.

                    method deregisterInteractionHandler

                    deregisterInteractionHandler: <K extends EventType>(
                    evtType: K,
                    handler: SpecificEventListener<K>
                    ) => void;
                    • Deregisters an event listener on the root element for a given event.

                    method getWidth

                    getWidth: () => number;
                    • Returns the width of the label element.

                    method registerInteractionHandler

                    registerInteractionHandler: <K extends EventType>(
                    evtType: K,
                    handler: SpecificEventListener<K>
                    ) => void;
                    • Registers an event listener on the root element for a given event.

                    method removeClass

                    removeClass: (className: string) => void;
                    • Removes a class from the label element.

                    Type Aliases

                    type MDCFloatingLabelFactory

                    type MDCFloatingLabelFactory = (
                    el: Element,
                    foundation?: MDCFloatingLabelFoundation
                    ) => MDCFloatingLabel;

                      Package Files (5)

                      Dependencies (8)

                      Dev Dependencies (0)

                      No dev dependencies.

                      Peer Dependencies (0)

                      No peer dependencies.

                      Badge

                      To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                      You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@material/floating-label.

                      • Markdown
                        [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@material/floating-label)
                      • HTML
                        <a href="https://www.jsdocs.io/package/@material/floating-label"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>