Created
August 19, 2020 19:02
-
-
Save akulsr0/cba59550d2c82d076ddd3e1a41da91fb to your computer and use it in GitHub Desktop.
React Native UI App - Top Tabs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { StyleSheet, Text, View } from 'react-native'; | |
// npm install @react-navigation/material-top-tabs react-native-tab-view | |
import { createMaterialTopTabNavigator } from '@react-navigation/material-top-tabs'; | |
function TabA() { | |
return ( | |
<View style={styles.container}> | |
<Text style={styles.text}>Tab A</Text> | |
</View> | |
); | |
} | |
function TabB() { | |
return ( | |
<View style={styles.container}> | |
<Text style={styles.text}>Tab B</Text> | |
</View> | |
); | |
} | |
function TabC() { | |
return ( | |
<View style={styles.container}> | |
<Text style={styles.text}>Tab C</Text> | |
</View> | |
); | |
} | |
const Tab = createMaterialTopTabNavigator(); | |
export default function TopTabs() { | |
return ( | |
<Tab.Navigator> | |
<Tab.Screen name='Tab A' component={TabA} /> | |
<Tab.Screen name='Tab B' component={TabB} /> | |
<Tab.Screen name='Tab C' component={TabC} /> | |
</Tab.Navigator> | |
); | |
} | |
const styles = StyleSheet.create({ | |
container: { | |
flex: 1, | |
alignItems: 'center', | |
justifyContent: 'center', | |
}, | |
text: { | |
fontSize: 30, | |
fontWeight: 'bold', | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://gist.github.com/akulsr0/570bb72afe45d82ca4d2b8420ed163c0