How to create Text Input in Alert Dialog in React Native

In this React Native source code example, the source code below illustrate how to create Text Input in Alert Dialog in React Native.

You can copy and adopt this source code example to your React Native project without reinventing the wheel.

import React, {Component} from 'react';
import { View,StyleSheet,TextInput,Button} from 'react-native';
import DialogInput from 'react-native-dialog-input';

export default class App extends Component {
  constructor(props) {
  this.state = { isAlertVisible:false };
    render() {
     return (
       <View style={styles.container}>
         <Button title="Open" onPress={()=>this.setState({isAlertVisible:true})} />
         <DialogInput isDialogVisible={this.state.isAlertVisible}
                     message={"Enter your name"}
                     hintInput ={"hint for the input"}
                     submitInput={ (inputText) => {this.submit(inputText)} }
                     closeDialog={ () =>this.setState({isAlertVisible:false})}>

const styles = StyleSheet.create({
  myInput: {
    backgroundColor: 'rgb(232, 232, 232)',
    borderRadius: 30,
    height: 40,
    width: '90%'},

  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#8ee3ab',

If you have any questions or suggestions kindly use the comment box or you can contact us directly through our contact page below.


Add a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.