react-responsive-input
customizable react text input
Use simple props to change the styles and functionality.
Themes and labels coming soon.
This is an alpha version. Please don't use it in production.
Demo at - http://quizzical-baby.surge.sh/
Install
npm install --save react-responsive-input
Usage
import React Component from 'react'import styled from 'styled-components'import InputComponent from 'react-responsive-input' const TestPage = styleddiv` height:100vh; width:100%; display:flex; justify-content:center; align-items:center;`const ParentStyle = styleddiv` height:35px; width:450px;` state = value:'' isFocused:false isError:false { } { const value = etargetvalue this } { this } { this } { console } { const value isFocused isError = thisstate return <TestPage> <ParentStyle> <InputComponent = = = = = // 's height width={''} // takes parent' // = // = = = = = = = /> </ParentStyle> </TestPage> }
Props Overview
InputpropTypes = value:PropTypesstring isFocused:PropTypesbool isError:PropTypesbool isFocusedByDefault:PropTypesbool height:PropTypesnode width:PropTypesnode maxLength:PropTypesnumber fontSize:PropTypesstring onChange:PropTypesfunc onBlur:PropTypesfunc onFocus:PropTypesfunc inputRef:PropTypesfunc
Props Configuration
-
If you pass no props, the default props take over. The input component maintains default state to store your input.
-
The event handler functions you pass as props are passed the synthetic event object of React as parameter.
-
The width and height can be set to a positive integer (treated in pixels). However, for a responsive behavior, just set the height and width to 'parent'. This will set the height and width of the input to 100% of the container's dimensions which wraps the input component. From there on, just control the parent's dimensions to control the input component's dimensions.
License
MIT © gulshanzealous