react-navigation / react-navigation

Routing and navigation for your React Native apps
https://reactnavigation.org
23.59k stars 5.04k forks source link

I need to style the outer most view of the header. #12160

Open Vimiso opened 1 month ago

Vimiso commented 1 month ago

Current behavior

Even when setting custom styles on a header they are still wrapped in a view I need access to.

Expected behavior

In a web environment, simply setting the header to transparent and adjusting the padding isn't sufficient because it places the scroll bar behind the header, resulting in an unpolished appearance. A better solution is to style the outermost view with position: sticky; top: 0, which ensures that the header remains fixed while the content scrolls beneath it, keeping the scroll bar visible and on top (similar to Twitter's sticky 'Post' header).

In the attached screenshot, you can see that applying custom styles to the outer view achieves the desired effect. Additionally, it shows my attempt to style the inner header using Tailwind CSS classes within a custom component via the header prop - however, this doesn't work as intended. As far as I know, there's no documented way to directly access or style the outer view in this scenario.

Screenshot 2024-09-20 at 18 34 14

Reproduction

https://snack.expo.dev/MhSky72WPBtM0_V48FVET

Platform

Packages

Environment

package version
@react-navigation/native
@react-navigation/bottom-tabs
@react-navigation/drawer
@react-navigation/material-top-tabs
@react-navigation/stack
@react-navigation/native-stack
react-native-safe-area-context
react-native-screens
react-native-gesture-handler
react-native-reanimated
react-native-tab-view
react-native-pager-view
react-native
expo
node
npm or yarn
github-actions[bot] commented 1 month ago

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.