Search code examples
react-nativereact-native-stylesheet

Default OS style in React Native


I'm starting with React Native and I'm wondering if is possible to apply the default OS style for each element so I have not the need to handle every element style so imagine I have a form and simple text list, for the iOS app it should have iOS form and text style and for the Android app its default style.

As far as I've seen there is no official documentation for this commitment but I would like to ask here if there is a workaround for this.


Solution

  • As far as I am aware the default components within React Native does normally default to the OS style, for instance the Button component will render differently according to each platform.

    As all the components that come with React Native are bare-bones, you'll have to define the styles yourself according to each platform which can be done with the Platform module: https://facebook.github.io/react-native/docs/platform-specific-code

    If you don't want to style each component yourself then you can use a library like: react-native-elements (https://react-native-training.github.io/react-native-elements/) which handles a lot of what you desire.