How to Use Styled Components in React Native
Covering installation, basic usage, props and TypeScript support
10 min readApr 16, 2020
Styled Components compliment React Native’s Stylesheet
Styled Components has been the most widely adopted solution for component-based CSS for a while now, with the package complimenting Javascript frameworks in general, in-particularly so for web-based applications.
But how effective is using Styled Components for React Native projects, that take a departure from styling DOM elements and instead require styling for JSX-Wrapped native mobile components? This article tackles this question by firstly looking at the differences between the two solutions, before exploring some implementations:
- The differences between Styled Components and React Native’s styling solution in accordance with
Stylesheet
will firstly be discussed, along with their benefits and shortcomings. - Implementation will then be explored, covering how to install and start using Styled Components within React Native, with useful use cases to start using it effectively with props.
- Finally, TypeScript support will be covered — a critical feature that Styled Components should use when a large amount of props are used.