Reputation: 2836
I want to make a "TypefaceTextInput" that will have a particular font and text color and will replace all TextInput in react native. This is so that I don't have to declare the font and text color everytime. Is there any way to do it?
I am new to react-native, but familiar with android in java and kotlin. If you can answer with an analogy to how we did it in java or kotlin, that would be very helpful.
Found this answer here which says
a library of components for our app that match the styles and naming of the style guide put together by our design team
But I think there will be extra nested components if we use this. Is there any way we can extend TextInput and do the needful in the child class?
Upvotes: 2
Views: 846
Reputation: 509
Check this module https://github.com/Ajackster/react-native-global-props
I have used it as
import {
setCustomTextInput,
setCustomText,
} from 'react-native-global-props';
// Setting default styles for all Text components.
const customTextProps = {
style: {
fontFamily: 'DINPro'
},
};
To add a custom font you can use the following tutorial https://medium.com/@kswanie21/custom-fonts-in-react-native-tutorial-for-ios-android-76ceeaa0eb78
Upvotes: 2