I am working on a react native project, using Expo router, to work on the header/ or topNavBar.
in the
<Stack.Screen name="usage" options={usageHeader}
there are differnt way to set the header, either a custom component for the whole header, by using header
, or using the navigation feature and then using of headerTitle
and headerLeft
and headerRight
. I am using the second approch because I don’t have to worry about safe area an so on. But the issue is that I couldn’t find a way to increase the height of the header.
headerStyle
only accepts backgroundColor.
Is there a olution for this, or am I missing something?
I found an issue about this on gitHub, but i didn’t see any solution apart from using header and defining a whole custom component.
https://github.com/react-navigation/react-navigation/issues/10097
headerStyle: { backgroundColor: '#E9FDFF', height: 100, // not doing anything marginTop: 100, // not doing anything paddingTop: 100, // not doing anything },
2
Answers
You can change backgroud and height props with headerStyle. But for headerStyle you cannot change margin or padding props, you can edit title instead.
Example:
With Expo Router, you can use
header
option with the<Header />
component and add the propsheaderStyle
Source: https://reactnavigation.org/docs/elements/#header