New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set header height in headerStyle in native-stack? #10097
Comments
Hey! Thanks for opening the issue. The issue doesn't seem to contain a link to a repro (a snack.expo.dev link or link to a GitHub repo under your username). Can you provide a minimal repro which demonstrates the issue? A repro will help us debug the issue faster. Please try to keep the repro as small as possible and make sure that we can run it without additional setup. |
Couldn't find version numbers for the following packages in the issue:
Can you update the issue to include version numbers for those packages? The version numbers must match the format 1.2.3. |
Couldn't find version numbers for the following packages in the issue:
Can you update the issue to include version numbers for those packages? The version numbers must match the format 1.2.3. |
+1 I am also seeing this issue going from v5 stack to v6 native-stack. Setting height on the headerStyle is no longer applying. |
I found a workaround for this issue.
But you would need to add the back arrow manually. |
Hello 👋, this issue has been open for more than a month without a repro or any activity. If the issue is still present in the latest version, please provide a repro or leave a comment within 7 days to keep it open, otherwise it will be closed automatically. If you found a solution or workaround for the issue, please comment here for others to find. If this issue is critical for you, please consider sending a pull request to fix it. |
@matias-calvo-91 Thanks! That worked for me. Do you know if it's possible to make the custom header absolute though? When I do so it disappears. |
Hey! This issue is closed and isn't watched by the core team. You are welcome to discuss the issue with others in this thread, but if you think this issue is still valid and needs to be tracked, please open a new issue with a repro. |
Setting the header height in the |
#10113 was supposed to fix this but setting height only works for web. |
Only works if you use custom |
setting the "header" prop in options, the height changes correctly, but the "headerLeft" and "headerRight" props stopping working. I defined some icons there. So if I'm not wrong, I'll need to add that icons inside the custom view defined in the "header" option. |
To anyone stumbling across this, I managed to get a workaround that worked for me which I can share. Whilst setting the
But with the following gotcha: The header height includes any insets due to the StatusBar, or any other notches. So, naively setting the header height to what you want it to be might cause issues on Android. If you want to set the header height to 100, you probably want to do something like:
I wanted to scale the header height depending on the screen size, for a fluid UI (don't ask...), and for me it was helpful to know the header's default height (i.e. what it is if you don't set it). To calculate this you can do:
|
Header height is managed here. It use default height when no custom header is provided... |
This has been an issue forever, please address it! Nothing in the docs admits that the height of the header cannot be changed, except by passing a completely custom header component, and then needing to reimplement all the react navigation built-in functionality for gesture, animation, etc, etc. Furthermore, when you pass a custom header component, it becomes impossible to keep the header above the content of the screen, even with messing with zIndex. This is a huge headache and something that should be extremely basic with the library. |
Damn, am I understanding this correctly that there is no way to change the height of the header other than a completely custom from-scratch header component? |
Question: How can I change the height of the nav component in React Navigation 6 with the new native-stack library? Current behavior: Expected behavior: Platform: Packages: |
if this is the case. Is there a guide on how to properly build a custom header? if i make my own implementation i always can't get it right with the transition, and the title |
In my case, I wrapped my app with "safe area insets" and found that my headers were too tall because they were including the status bar height. So I tried using the header: () => <Header title="test" />, and then I commented it out and found that the original header was now the correct size. This just seems like buggy behavior but maybe it's the bug you're looking for! TL;DRTry
and then use the |
Can this be reopened because of https://x.com/swmansion/status/1714324990491762873?s=46 |
I had to use a custom Header component to get it to work. |
I've tried this, but I lose the back button and any |
@dgrcode if you use a custom |
I'd love to have control over the height too. |
why is this closed? |
Experiencing the same issue, need to pass a custom header component instead which is annoying. |
Experiencing the same issue and it's extremely annoying |
Current behavior
I am migrating to react navigation 6 and I want to use the new standard native-stack library to upgrade the performance of these stacks. I have from react-navigation 5 this stack navigator (a snippet):
Screen1StackNavigator:
return ( <Stack.Navigator screenOptions={{ headerStyle: { height: 100, backgroundColor: 'black', }, }} > <Stack.Screen name="Screen1" component={Screen1} options={{ headerTitle: () => <Title title={'Screen1'} />, }} /> </Stack.Navigator> )
This snippet is in this tree of the main navigator:
MainTabsNavigator:
<Tab.Navigator screenOptions={{ lazy: true, headerShown: false, }} ... > <Tab.Screen name="Screen1" component={Screen1StackNavigator} options={{ TabLabel: t('markets.title'), }} />...
But with this native-stack, the header style cant set its height. I saw in the docs that the only props you can set are:
Style object for header. Supported properties:
backgroundColor
So I want to know if there is a hidden tricky way to set the height as I used to do in react navigation 5 with "default" stack.
Expected behavior
Set the inner Stack Header Height to a specific height.
Reproduction
Platform
Packages
Environment
"@react-navigation/bottom-tabs": "^6.0.9",
"@react-navigation/drawer": "^6.1.8",
"@react-navigation/elements": "^1.2.1",
"@react-navigation/native": "^6.0.6",
"@react-navigation/native-stack": "^6.2.5",
"@react-navigation/stack": "^6.0.11",
The text was updated successfully, but these errors were encountered: