Giter Site home page Giter Site logo

scout24 / react-floating-label-input Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cymen/react-floating-label-input

0.0 3.0 0.0 1.42 MB

A floating label input component for React with control over label shrinking percentage.

Home Page: http://blog.cymen.org/react-floating-label-input

License: MIT License

JavaScript 36.31% CSS 15.56% HTML 45.49% SCSS 2.64%

react-floating-label-input's Introduction

react-floating-label-input

License Downloads

npm badge

This is a floating label component for React. It inherits the font-size from the parent so you can easily set the desired input font-size in your own CSS. It also accepts a shrink property which can be 1-99 inclusive. That is the percentage the label should be of the input font size. That means if you have a font size of 20px on the input, the default 70% will result in a 14px label size (20 * 0.7 = 14).

Examples

Visual

Try it yourself at the Storybook.

Screenshot

Code

Here is the 3rd example above in JSX (64px font size with 20% label shrinkage):

import React from 'react';
import FloatingLabelInput from 'react-floating-label-input';
import 'react-floating-label-input/dist/react-floating-label-input.css';

export default ({ onChange, value }) =>
  <div style={{ fontSize: 64 }}>
    <FloatingLabelInput
      id="example-3"
      label="label"
      onChange={onChange}
      shrink={20}
      value={value}
    />
  </div>;

Props

name optional default
fontSize yes inherit
id no
label no
onBlur yes
onChange no
onFocus yes
placeholder yes ''
shrink yes 70%
type yes text
value yes ''

Styling

The component renders with a DOM class of react-floating-label-input.

Dependencies

Peer dependencies:

  • react
  • react-dom
  • classnames

License

MIT

react-floating-label-input's People

Contributors

cymen avatar advanced-security-actions-deployer[bot] avatar

Watchers

Ralph Angenendt avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.