Material Design for React Native
React Native Paper is an actively maintained cross-platform UI kit library for React Native, currently at version 5.15.1. It provides a comprehensive collection of customizable and production-ready components that strictly adhere to Google's Material Design guidelines, including full support for Material Design 3 (MD3). The library offers robust theming capabilities, allowing developers to easily adapt the visual style of their applications. It maintains a regular release cadence with frequent bug fixes and minor versions introducing new features or deprecations. Key differentiators include its deep integration with Material Design principles, its platform adaptation for both iOS and Android, and its comprehensive theming system, making it a strong choice for building consistent and aesthetically pleasing React Native applications.
Common errors
-
Menu briefly flashes on first open
cause An intermittent rendering issue affecting the `Menu` component's initial appearance.fixUpgrade to `react-native-paper@5.15.1` or newer, as this bug was addressed in that release. -
Error on width change of AnimatedFAB when label is empty string
cause A specific bug where the `AnimatedFAB` component would throw an error when its `label` prop was an empty string and its width changed.fixUpdate to `react-native-paper@5.14.2` or later, which contains a fix for this issue. -
TextInput label not animating or incorrectly positioned (especially 'outlined' or 'flat' variants)
cause Issues with `transformOrigin` internally applied to `TextInput` components were causing label rendering glitches.fixEnsure you are using `react-native-paper@5.14.3` or newer, where the problematic `transformOrigin` usage was reverted to resolve these issues. -
Surface component styling incorrect when `flex` property is set
cause A bug in `Surface` component's styling where the `flex` prop was not correctly applied or interfered with other styles.fixUpgrade to `react-native-paper@5.14.1` or later, as this specific issue regarding `Surface` styling with `flex` was resolved.
Warnings
- deprecated The `createMaterialBottomTabNavigator` utility has been deprecated in `react-native-paper@5.14.0`. It is no longer actively maintained or recommended for new projects.
- gotcha Support for `transformOrigin` on `TextInput` components was temporarily unstable and removed in `v5.14.3` due to various label rendering issues. This might affect custom animations or styling that relied on `transformOrigin`.
- gotcha The internal use of `findNodeHandle` was removed in `v5.14.2`. While this typically affects library internals, it might indicate changes in how certain components interact with the native view hierarchy, potentially impacting highly customized or native-module-integrated components.
- gotcha Version `5.14.1` introduced explicit support for `react-native` 0.77.0 and `@react-native-vector-icons` 12.x. Using significantly older or newer versions of these peer dependencies may lead to unexpected visual glitches or runtime errors.
Install
-
npm install react-native-paper -
yarn add react-native-paper -
pnpm add react-native-paper
Imports
- Provider
const { Provider } = require('react-native-paper')import { Provider } from 'react-native-paper' - Button
import Button from 'react-native-paper/lib/components/Button'
import { Button } from 'react-native-paper' - MD3LightTheme, useTheme
import { DefaultTheme } from 'react-native-paper' // Deprecated for MD3import { MD3LightTheme, Provider, Text, useTheme } from 'react-native-paper'
Quickstart
import * as React from 'react';
import { View, StyleSheet } from 'react-native';
import { Button, MD3LightTheme, PaperProvider, Text, Appbar } from 'react-native-paper';
const theme = {
...MD3LightTheme,
colors: {
...MD3LightTheme.colors,
primary: '#673ab7',
accent: '#ff4081',
},
};
export default function App() {
const [count, setCount] = React.useState(0);
return (
<PaperProvider theme={theme}>
<Appbar.Header>
<Appbar.Content title="My Paper App" />
</Appbar.Header>
<View style={styles.container}>
<Text variant="headlineMedium">Count: {count}</Text>
<Button
mode="contained"
onPress={() => setCount(c => c + 1)}
style={styles.button}
>
Increment
</Button>
<Button
mode="outlined"
onPress={() => setCount(0)}
style={styles.button}
>
Reset
</Button>
</View>
</PaperProvider>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
padding: 16,
backgroundColor: theme.colors.background,
},
button: {
marginVertical: 8,
width: 200,
},
});