If you are starting a new project, please try gluestack-ui for better performance and new design.
Utility First
React Native has a great StyleSheet API which is optimal for component-based systems. NativeBase leverages it and adds a layer of utility props and constraint based designed tokens on top of it.
To understand utility props, let's take an example.
With React Native
Let's try the traditional way of building the following card in React Native.
Playground
functionExample(){
return<Viewstyle={styles.container}>
<Viewstyle={styles.topContainer}>
<Viewstyle={styles.metaContainer}>
<View>
<Textstyle={styles.timings}>Today @ 9PM</Text>
<Textstyle={styles.description}>Let's talk about avatar!</Text>
components. This approach allows us to style components without using StyleSheet API.
Apart from productivity boosts and saving time, there are other benefits to styling components using utility props.
No need to name styles anymore, no need to define an object and think about naming it.
Using utility-first props, you can focus on creating reusable components instead of reusable stylesheets.
Once you start writing styles this way, any other way will feel cumbersome.
Put simply, utility first approach opens up the Avatar state within developers.
Once you had a cup of tea, let's proceed to the next section!