react-native-paper icon indicating copy to clipboard operation
react-native-paper copied to clipboard

[Surface] `shadowColor` should follow the current theme by default

Open fabriziocucci opened this issue 10 months ago • 1 comments

Current behaviour

It looks like the shadowColor of the Surface component has been hardcoded to pure black here.

That causes the shadow not to show up on other components that are backed by Surface (e.g. Card).

Expected behaviour

I'm not 100% sure of what the spec says but I believe the shadowColor should be set to something like theme.colors.onBackground by default to provide the necessary contrast.

How to reproduce?

  1. set a dark theme (e.g. where theme.colors.background = 'black')
  2. place a Card on the screen

Preview

  • With the current shadowColor:
Image
  • With the shadowColor set to theme.colors.onBackground:
Image

What have you tried so far?

I need to manually set shadowColor on each elevated component that requires a shadow.

Your Environment

software version
ios Unnecessary
android Unnecessary
react-native Unnecessary
react-native-paper 5.13.1
node Unnecessary
npm or yarn Unnecessary
expo sdk Unnecessary

fabriziocucci avatar Feb 26 '25 09:02 fabriziocucci

Seems as though the spec suggests it should always be #000000 (md.sys.color.shadow) regardless of theme or contrast options https://m3.material.io/components/cards/specs#daab7734-3b3e-464c-a967-7c7fa14e6478

Image

So I guess the question is should RNP provide a global override for shadowColor via the theme?

raldred avatar Aug 21 '25 17:08 raldred