3

I couldn't manage to change the style of TextInput in React Native when the secureTextEntry prop set to true. Also the default style of input changes, I understood this is due to android native behaviour. The below code does not change the style unless I unset secureTextEntry.

<TextInput secureTextEntry={true} style={{color: "white"}}/>

I have a login form and having different styles for email input and password input is disturbing. Does anyone know how to fix this?

UPDATED

Seems like the following PR will fix the issue:

PR Link

3 Answers 3

4

<TextInput
          placeholder={'Environment'}
          placeholderTextColor="#202020"
          secureTextEntry={true}
        />

Sign up to request clarification or add additional context in comments.

Comments

1

This PR has now been merged to fix it, and it should probably land in 0.23.

If like me, you don't want to wait for it, or can't upgrade easily, you can use this module I created, as described in this blog post.

Basically, install the module with:

npm install --save react-native-text-input

Link it to your native code: I strongly recommend the use of RNPM to link native modules:

npm install -g rnpm
rnpm link react-native-text-input

Now you can replace:

import { TextInput } from 'react-native';

by:

import TextInput from 'react-native-text-input';

And tadaaaaa! Your input is now white :)

The TextInput from this module is actually a copy-paste from the default React Native one, with the fix in the PR above added.

Comments

0

It's a known RN issue. You can track it here. Unless you submit a PR, I think we'll have to wait for that feature to come.

1 Comment

Seems like the following PR will fix the issue. Thanks. github.com/facebook/react-native/pull/6064

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.