0

Recently I was trying to use react native paper library in my application. But when I try to add background color using their custom theme option in PaperProvider component, Then it is not working. Can someone please help me to fix this I have to apply custom background color on complete screen using custom theme in react native paper PaperProvider.Below is my source code.

import * as React from 'react';
import { DefaultTheme, Provider as PaperProvider } from 'react-native-paper';
import { SafeAreaView, StyleSheet, View } from 'react-native';
export default function Main() {
 const mainTheme = {
...DefaultTheme,
colors: {
  ...DefaultTheme.colors,
  primary: 'tomato',
  accent: 'yellow',
  background: 'red'
},
  };
return (
<PaperProvider theme={mainTheme}>

</PaperProvider>
  );

}
Drew Reese
  • 165,259
  • 14
  • 153
  • 181
Juned
  • 51
  • 1
  • 2
  • 4
  • Can you describe in more detail what exactly isn't working? Think you could create a *running* [Expo snack](https://expo.dev/snacks) of your code that reproduces the issue that we could inspect and debug live? – Drew Reese Jan 11 '22 at 05:11
  • Bro, All I need is add background color on my screen using custom theme in react native paper ? Can you help me . – Juned Jan 11 '22 at 05:27

1 Answers1

0

You can wrap your content using a View component with the theme background color as its backgroundColor value:

<PaperProvider theme={mainTheme}>
  <View style={{ flex: 1, backgroundColor: theme.colors.background }}>
    ...
  </View>
</PaperProvider>
Augusto Franzoia
  • 570
  • 3
  • 13