Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@indec/react-native-md-textinput

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@indec/react-native-md-textinput

React Native TextInput styled with Material Design.

  • 3.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
2
Weekly downloads
 
Created
Source

React Native Material Design TextInput

React Native TextInput styled with Material Design.

demo

Installation

npm install react-native-md-textinput

Usage

I'm going to refer to the react-native-md-textinput Component as TextField. You can name it whatever you like when importing it.

The most basic usage is to import the TextField Component and render it with the props label and highlightColor. Note that this example uses the ScrollView Component. This allows the keyboard to be dismissed when users tap outside the input and keyboard area.

import TextField from 'react-native-md-textinput';

class App extends React.Component {
  render() {
    return (
      <ScrollView>
        <TextField label={'Name'} highlightColor={'#00BCD4'} />
      </ScrollView>
    );
  }
}

TextInput

To customize the TextInput that is rendered inside the TextField Component, simply pass props the TextInput accepts to the TextField Component. You can find the props the TextInput Component accepts here.

Here is an example of how to change the keyboard type to numeric.

import TextField from 'react-native-md-textinput';

class App extends React.Component {
  render() {
    return (
      <ScrollView>
        <TextField
          label={'Name'}
          highlightColor={'#00BCD4'}
          keyboardType={'numeric'}
        />
      </ScrollView>
    );
  }
}

Dense Styling

To use the "dense" styling that matches the Material Design Style Guide, you can set the prop dense to true. By default, this prop is set to false.

demo dense

Props

Below are the props you can pass to the React Component to customize the TextInput.

PropTypeDefaultdescription
labelstringThis string appears as the label.
highlightColorstringThis string represents the hex code, rgb, or rgba color of the TextInput label and underline when it is active/focused on.
durationnumber200A number representing the duration of floating label and underline animations in milliseconds.
labelColorstring#9E9E9EThis string represents the hex code, rgb, or rgba color of the TextInput label when it is inactive.
textColorstring#000This string represents the hex code, rgb, or rgba color of the text entered in the TextInput. Note: If you set textFocusColor or textBlurColor, those colors will override this one during the corresponding state of the TextInput.
textFocusColorstringThis string represents the hex code, rgb, or rgba color of the text entered in the TextInput when it is active/focused on.
textBlurColorstringThis string represents the hex code, rgb, or rgba color of the text entered in the TextInput when it is inactive.
borderColorstring#E0E0E0This string represents the hex code, rgb, or rgba color of the TextInput underline when it is inactive.
denseboolfalseIf true, it will render the "dense" input field which is smaller in height and has smaller font sizes. You can view more here.
multilineboolfalseIf true, it will allow multiline text input
heightnumberundefinedA number representing the initial height of the textInput
autoGrowboolfalseIf true enables autogrow of the textInput
underlineColorAndroidstringrgba(0,0,0,0)This sets the default underline color on Android to transparent (Issue #1).

Style Overrides

The main purpose of this component is to easily add a TextInput that matches the Material Design Style Guide. With that said, there have been requests (i.e. PR #4) to style the component beyond the Material Design Style Guide. I've added the props below to allow you to do exactly that. DO THIS AT YOUR OWN RISK. Changing the layout requires an understanding of the main elements of this component (i.e. FloatingLabel, the Viewwrapper, and the TextInput), and may cause compatibility issues between Android and iOS (Issue #2). I'll try to support any issues with these props, but they will be treated as second class citizens.

PropTypeDefaultdescription
inputStyleObjectObject to override the styles of the TextInput.1
wrapperStyleObjectObject to override the styles of the View that wraps the TextInput.1
labelStyleObjectObject to override the styles of the Label that animates on focus of the TextInput.1

1: Object to override styles needs to match the format of inline styles. You can find the supported properties here.

TODO

  • Support multi-line TextInput fields
  • Support character limit
  • Add option for dark theme

Keywords

FAQs

Package last updated on 28 Aug 2018

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc