Search code examples
react-nativetextinput

How can I put an button on right side to FormInput in React Native?


I am using TextInput but unable to set its width can any one help me out to design a FormInput with a button on right side. if its join together that will nice

iam using

<View style={{ flexDirection: "row"}}>
                <Ionicons.Button name="md-arrow-round-back" backgroundColor="#FFF" color="#00AEEB" size={25} onPress={()=>this.props.navigation.navigate('ScreenOne')}/>
                <FormInput autoFocus={true} placeholder="Comment" onChangeText={(comment) => this.setState({comment})} />
                <Ionicons.Button name="md-checkmark" backgroundColor="#0f0" color="#fff" size={25} onPress={()=>this.props.navigation.navigate('ScreenOne')}/>

            </View>

Solution

  • <View style={{ flexDirection: "row"}}>
      <View style={{ width: "10%", height: 40}}>
        <Ionicons.Button name="md-arrow-round-back" style={{ width: "100%"}} backgroundColor="#FFF" color="#00AEEB" onPress={()=>this.props.navigation.navigate('ScreenOne')}/>
      </View>
      <View style={{ width: "80%", height: 40}}>
        <FormInput autoFocus={true}  placeholder="Comment" onChangeText={(comment) => this.setState({comment})}  />
      </View>
      <View style={{ width: "10%", height: 40, backgroundColor:"#fff", borderRadius: 50}}>
        <Ionicons.Button name="md-checkmark" style={{ width: "100%", borderRadius: 50}} backgroundColor="#548e59" color="#fff"/>
      </View>
    </View>