Comments (2)
You can do this by moving <View name="plan" style={styles.tabButtons}><Icon size={25} name="dot-circle-o"/><Text>Plan</Text></View>
to a new component, maybe you could call it as TabBarItem
then use it like <TabBarItem name='plan' selectedStyle={{ color: 'red' }} />
. After that, on your TabBarItem
component you can get the selectedStyle on your props.
Here is my sample code:
import React from 'React'
import { View, Text } from 'react-native'
import Icon from 'react-native-vector-icons/Ionicons';
const TabBarItem = ({ name, selectedItem, selectedStyle, text, icon }) => {
const {
iconTextWrapperStyle,
iconStyle,
textStyle
} = styles
return (
<View style={iconTextWrapperStyle}>
<Icon name={icon} style={[iconStyle, selectedItem === name ? selectedStyle : {}]}/>
<Text style={[textStyle, selectedItem === name ? selectedStyle : {}]}>{text}</Text>
</View>
)
}
const styles = {
iconTextWrapperStyle: {
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center'
},
iconStyle: {
fontSize: 25,
color: 'grey'
},
textStyle: {
fontSize: 10,
color: 'grey'
}
}
export default TabBarItem
from react-native-tabs.
Closing for good answer
from react-native-tabs.
Related Issues (20)
- Tab bar sometimes is pushed up by the keyboard. HOT 20
- Display Tab View on Top HOT 2
- With router-flux: Tab re-renders one more time HOT 5
- Single child doesn't work HOT 1
- Tabs scrolling HOT 3
- Doesn't work with Navigator
- selectedStyle don't work.
- React Native Tabs Not Showing Up
- not working using <Tabs><View name=""> HOT 2
- Tab bar position - Incomplete Doc HOT 1
- Does not work for falsey values of name
- tabs how to combine with router-flex?
- Unsupported top level event type "topScrollBeginDrag" dispatched
- create if else in ROOT scene for choose tabs component
- Reload selected tab if again tap on same tab icon
- Need example for flux tab content navigation HOT 1
- this project doesnt work anymore HOT 4
- tabs selection fails on child with name=0
- TextInput with Tabs issue on Android and iOS
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-tabs.