Styling
suggest changeIntroduction
Styles are plain objects whose property names are mostly CSS names in camelCase. Put the object inline on a component's style prop, or pass it to StyleSheet.create and keep the result in a variable, then refer to it by name, similar to a CSS class.
Syntax
<Component style={styleFromStyleSheet} /><Component style={styleObject} /><Component style={[style1,style2]} />
Remarks
Most React Native style names are the CSS names written in camelCase. Some names differ. CSS text-decoration is textDecorationLine.
Unlike in CSS, styles do not get inherited. If you want child components to inherit a certain style, you must explicitly provide it to the child. This means that you cannot set a font family for an entire View.
The one exception to this is the Text component: nested Texts inherit their parent styles.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents