Styles
React Native allows you to style components using a subset of CSS properties as inline styles. For layout only the flexbox module and absolute positioning is available. The style properties are split into five categories:
View Properties
Image Properties
Text Properties
Flex Properties
Transform Properties
Usage for Static Styles
Use StyleSheet.create
to construct styles and define them at the end of the file. This ensures that the values are immutable and they are only created once for the application and not on every render.
You can also compose styles
Usage for Dynamic Styles
Dynamic styles can be created as objects in the render. However, the official documentation recommends that you avoid this:
Finally, if you really have to, you can also create style objects in render, but they are highly discouraged. Put them last in the array definition.
Last updated