Skip to content
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

Cannot style shadow in react navigation header #11970

Closed
3 of 11 tasks
demoox opened this issue May 1, 2024 · 8 comments
Closed
3 of 11 tasks

Cannot style shadow in react navigation header #11970

demoox opened this issue May 1, 2024 · 8 comments

Comments

@demoox
Copy link

demoox commented May 1, 2024

Current behavior

I tried this:

screenOptions={{
  headerShown: true,
  headerStyle: {
    backgroundColor: '#4aceaf',
    shadowColor: '#000',
    shadowOffset: { width: 0, height: 4 },
    shadowOpacity: 1,
    shadowRadius: 5,
    elevation: 5
  },
  headerTitle: 'Home', 
  headerTintColor: '#000',
  headerTitleStyle: {
    fontSize: 15, 
  }, 
  headerShadowVisible: false
}}

I also tried this:

screenOptions={{
  headerShown: true,
  headerStyle: {
    backgroundColor: '#4aceaf
  },
contentStyle: {
    shadowColor: '#000',
    shadowOffset: { width: 0, height: 4 },
    shadowOpacity: 1,
    shadowRadius: 5,
    elevation: 5
},
  headerTitle: 'Home', 
  headerTintColor: '#000',
  headerTitleStyle: {
    fontSize: 15, 
  }, 
  headerShadowVisible: false
}}

no shadow appears:
obtained

Expected behavior

expected

Reproduction

https://snack.expo.dev/@demoox/cannot-style-shadow-header

Platform

  • Android
  • iOS
  • Web
  • Windows
  • MacOS

Packages

  • @react-navigation/bottom-tabs
  • @react-navigation/drawer
  • @react-navigation/material-top-tabs
  • @react-navigation/stack
  • @react-navigation/native-stack
  • react-native-tab-view

Environment

package version
@react-navigation/native "^6.0.2"
@react-navigation/native-stack "^6.9.17"
@react-navigation/stack "^6.3.29"
react-native-gesture-handler "~2.14.0"
react-native-safe-area-context "4.8.2"
react-native-screens "~3.29.0"
react-native "0.73.6"
expo "~50.0.14"
Copy link

github-actions bot commented May 1, 2024

The versions mentioned in the issue for the following packages differ from the latest versions on npm:

  • @react-navigation/native (found: 6.0.2, latest: 6.1.17)

Can you verify that the issue still exists after upgrading to the latest versions of these packages?

@demoox
Copy link
Author

demoox commented May 1, 2024

The versions mentioned in the issue for the following packages differ from the latest versions on npm:

  • @react-navigation/native (found: 6.0.2, latest: 6.1.17)

Can you verify that the issue still exists after upgrading to the latest versions of these packages?

The problem persists

@demoox
Copy link
Author

demoox commented May 3, 2024

Anyone have a solution?

@satya164
Copy link
Member

satya164 commented May 3, 2024

As documented on this page, the only supported property is backgroundColor

https://reactnavigation.org/docs/native-stack-navigator/#headerstyle

@satya164 satya164 closed this as not planned Won't fix, can't repro, duplicate, stale May 3, 2024
Copy link

github-actions bot commented May 3, 2024

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.

@demoox
Copy link
Author

demoox commented May 3, 2024

ds

Comme indiqué sur cette page, la seule propriété prise en charge estbackgroundColor

https://reactnavigation.org/docs/native-stack-navigator/#headerstyle

@satya164 Can you provide a clearer answer or solution instead of simply closing the topic?
Is it possible to add a custom shadow other than in headerStyle? because many apps do it

@satya164
Copy link
Member

satya164 commented May 3, 2024

As I already wrote, the only supported property is backgroundColor. "only" means there's nothing else that's supported, which means shadow is not supported. Please try to read next time.

@satya164
Copy link
Member

satya164 commented May 3, 2024

@demoox native stack is less customizable as mentioned on top of the page and only supports what's supported by Android/iOS. If you want more customization you either need to use a custom header with the header option, or use JS stack (@react-navigation/stack).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants