Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simplest way to cascade styles in react native

I see that in react native if I set a fontFamily in a, for example, a View, the inner elements do not inherit it the property. Is it there a cascade concept available in react native styling? How do I accomplish it?

like image 521
R01010010 Avatar asked Dec 23 '16 21:12

R01010010


People also ask

How do you give multiple styles in React Native?

react-native Styling Adding multiple styles You can pass an array to the style prop to apply multiple styles. When there is a conflict, the last one in the list takes precedence.

What are the different ways to style React Native application?

With React Native, you style your application using JavaScript. All of the core components accept a prop named style . The style names and values usually match how CSS works on the web, except names are written using camel casing, e.g. backgroundColor rather than background-color .

How do you define global styles in React Native?

To create global styles with React Native, we can create a module that exports the stylesheet object. import * as React from 'react'; import { View, Text, Button } from 'react-native'; import { Card } from 'react-native-paper'; import styles from './styles'; const App = () => { return ( <View> <Text style={styles.


Video Answer


1 Answers

Apparently at this moment a component can only inherit a property of a parent only if the parent is of the same type or at least also support the property to inherit. I was setting fontFamily in the main View component and wasn't being inherited in the Text children.

like image 117
R01010010 Avatar answered Oct 08 '22 18:10

R01010010