How do you style a TextInput in react native for password input

bwbrowning picture bwbrowning · Mar 30, 2015 · Viewed 138.4k times · Source

I have a TextInput. Instead of showing the actual text entered, I want it to show asterisks (****) when the user enters text. How can I do this?

<TextInput
  style={{ height: 40, borderColor: 'gray', borderWidth: 1 }}
  onChangeText={(text) => this.setState({input: text})}
/>

Answer

Riley Bracken picture Riley Bracken · Mar 30, 2015

When this was asked there wasn't a way to do it natively, however this will be added on the next sync according to this pull request. Here is the last comment on the pull request - "Landed internally, will be out on the next sync"

When it is added you will be able to do something like this

<TextInput secureTextEntry={true} style={styles.default} value="abc" />

refs