Is there a way in React Native that I can put all of my styles in a single file so it can easily be maintained (from my perspective) like in HTML we have a .css
file.
And also I have a module where there are different styles based on a current user.
React Native lets you style your whole application using JavaScript. Every component can use a prop named style , which enables you to write CSS styles for those components. There are two main methods that React Native has for creating styles: inline styling and using a style prop to style subcomponents.
A StyleSheet is an abstraction similar to CSS StyleSheets. Instead of creating a new style object every time, StyleSheet helps to create style objects with an ID which is further used to reference instead rendering it again.
You could simply create a Styles component like so with all your styles...
import { StyleSheet } from "react-native" export default StyleSheet.create({ ... })
Then on any view needing styles, simply require it...
import styles from "./Styles"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With