0.1.0 • Published 5 years ago

react-native-mask-textinput v0.1.0

Weekly downloads
1
License
ISC
Repository
-
Last release
5 years ago

react-native-mask-textinput

You can integrate this component in your code very easily. Just install by

yarn add react-native-mask-textinput

OR

npm install react-native-mask-textinput

Example:

.
.
import MaskField from "react-native-mask-textinput";
.
.

export default class App extends Component {
  constructor(props) {
    super(props);
    this.state = { text: "" };
  }

  onTextChange = (value) => {
    this.setState({ text: value });
  };

  render() {
    return (
      <View style={styles.container}>
        <MaskField
          mask="[000][0000000]" // no spaces between square brackets
          keyboardType="numeric"
          value={this.state.text}
          onChangeText={this.onTextChange}
          delimiter=" "
        // countryCode="+9"
        //  countryCodeContainerStyle={{backgroundColor: "grey"}}
        //  countryCodeTextStyle={{color: "red"}}
        />
      </View>
    );
  }
}



const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: "#fff",
    alignItems: "center",
    justifyContent: "center",
  },
});

Simple

Simple

With Country Code

With Country Code

PropsDescription
valueSet value of input field
onChangeTextTakes a function to be called every time the text changed
Mask"00" this will give "12 34". Dont give space in square brackets. Curly brackets are accepted in square brackets like "(000)" which will give "(123) 45".
DelimiterDefault delimiter is " " space. You can use delimiter like "-"
countryCodeYou can also put a constant before input field. This is optional
countryCodeContainerStyleStyling country code container. Optional field
countryCodeTextStyleStyling country code Text. Optional field