Skip to content

Incorrect styling on SnackBar #4044

@thrandale

Description

@thrandale

Current behaviour

It appears that the IconButton inside the snackbar is not properly styled to handle a color change of the snackbar.
IMG_062353E4D1C2-1

Expected behaviour

IMG_4015A60C39C1-1

How to reproduce?

return (
  <Portal>
    <Snackbar
      onIconPress={closeSnackBar}
      visible={true}
      theme={{
        colors: {
          inverseSurface: 'rgb(62, 35, 95)',
          inverseOnSurface: 'rgb(120, 69, 185)',
        },
      }}
      onDismiss={closeSnackBar}>
      Snack bar message
    </Snackbar>
  </Portal>
);

What have you tried so far?

I temprarily applied a patch with patch-package.

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-paper/src/components/Snackbar.tsx b/node_modules/react-native-paper/src/components/Snackbar.tsx
index 388fc48..9f53289 100644
--- a/node_modules/react-native-paper/src/components/Snackbar.tsx
+++ b/node_modules/react-native-paper/src/components/Snackbar.tsx
@@ -328,6 +328,7 @@ const Snackbar = ({
                 accessibilityRole="button"
                 borderless
                 onPress={onIconPress}
+                containerColor={theme.colors.inverseSurface}
                 iconColor={theme.colors.inverseOnSurface}
                 rippleColor={rippleColor}
                 theme={theme}

Your Environment

software version
ios 17
android 13
react-native 0.72.3
react-native-paper 5.10.0
node 20.5.1
npm 9.8.1
expo sdk N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions