Categories
JavaScript Answers React Native Answers

How to change the React Native text input cursor color?

Spread the love

Sometimes, we want to change the React Native text input cursor color.

In this article, we’ll look at how to change the React Native text input cursor color.

How to change the React Native text input cursor color?

To change the React Native text input cursor color, we can set the selectionColor prop to the cursor color.

For instance, we write:

import * as React from 'react';
import { View, TextInput } from 'react-native';
import Constants from 'expo-constants';
import { Card } from 'react-native-paper';

export default function App() {
  return (
    <View style={{ flex: 1 }}>
      <TextInput selectionColor="green" placeholder="name" />
    </View>
  );
}

to set selectionColor to 'green' to set the cursor color on the text input to green.

Conclusion

To change the React Native text input cursor color, we can set the selectionColor prop to the cursor color.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *