Skip to content

Commit 30cd1fe

Browse files
committed
docs: update documentation
1 parent cf203b2 commit 30cd1fe

5 files changed

Lines changed: 107 additions & 223 deletions

File tree

docs/docs/guides/01-getting-started.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ title: Getting Started
1212
npm install react-native-paper
1313
```
1414

15-
- From `v5` there is a need to install [react-native-safe-area-context](https://github.com/th3rdwave/react-native-safe-area-context) for handling safe area.
15+
- Install [react-native-safe-area-context](https://github.com/th3rdwave/react-native-safe-area-context) for handling safe area.
1616

1717
```bash npm2yarn
1818
npm install react-native-safe-area-context
@@ -136,22 +136,19 @@ export default function Main() {
136136

137137
## Customization
138138

139-
You can provide a custom theme to customize the colors, typescales etc. with the `Provider` component. Check the [Material Design 3 default theme](https://github.com/callstack/react-native-paper/blob/main/src/styles/themes/v3/LightTheme.tsx) to see what customization options are supported.
139+
You can provide a custom theme to customize the colors, typescales etc. with the `Provider` component. Check the [default theme](https://github.com/callstack/react-native-paper/blob/main/src/theme/schemes/LightTheme.tsx) to see what customization options are supported.
140140

141141
Example:
142142

143143
```js
144144
import * as React from 'react';
145-
import {
146-
MD3LightTheme as DefaultTheme,
147-
PaperProvider,
148-
} from 'react-native-paper';
145+
import { LightTheme, PaperProvider } from 'react-native-paper';
149146
import App from './src/App';
150147

151148
const theme = {
152-
...DefaultTheme,
149+
...LightTheme,
153150
colors: {
154-
...DefaultTheme.colors,
151+
...LightTheme.colors,
155152
primary: 'tomato',
156153
secondary: 'yellow',
157154
},

docs/docs/guides/02-theming.mdx

Lines changed: 65 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default function Main() {
2828
}
2929
```
3030

31-
By default React Native Paper will apply the [Material You theme (MD3)](https://github.com/callstack/react-native-paper/blob/main/src/styles/themes/v3/LightTheme.tsx) if no `theme` or `version` prop is passed to the `PaperProvider`.
31+
By default React Native Paper will apply `LightTheme` if no `theme` prop is passed to the `PaperProvider`, automatically switching to `DarkTheme` when the device color scheme is dark.
3232

3333
## Accessing theme properties
3434

@@ -62,12 +62,9 @@ export default withTheme(PaymentScreen);
6262

6363
You can change the theme prop dynamically and all the components will automatically update to reflect the new theme.
6464

65-
A theme usually contains the following properties:
65+
A theme contains the following properties:
6666

6767
- `dark` (`boolean`): whether this is a dark theme or light theme.
68-
- `version`: Material You (MD3); kept for compatibility and normalized to `3` by `PaperProvider`
69-
- `mode` (`'adaptive' | 'exact'`): color mode for dark theme (See [Dark Theme](#dark-theme)).
70-
- `roundness` (`number`): roundness of common elements, such as buttons.
7168
- `colors` (`object`): various colors used throughout different elements.
7269

7370
> The primary key color is used to derive roles for key components across the UI, such as the FAB, prominent buttons, active states, as well as the tint of elevated surfaces.
@@ -143,34 +140,39 @@ A theme usually contains the following properties:
143140
- `fontWeight`
144141
- `lineHeight`
145142
- `fontSize`
146-
- `animation` (`object`)
147-
- `scale` - scale for all animations
148-
149-
When creating a custom theme, you will need to provide all of these properties.
150-
151-
If you don't use a custom theme, Paper will automatically turn animations on/off, depending on device settings.
152-
153-
Otherwise, your custom theme will need to handle it manually, using React Native's [AccessibilityInfo API](https://reactnative.dev/docs/accessibilityinfo).
143+
- `state` (`object`): interaction state opacity layers per the Material Design 3 spec.
144+
- `opacity` - opacities for each interaction state: `hovered` (0.08), `focused` (0.1), `pressed` (0.1), `dragged` (0.16), `disabled` (0.38), `enabled` (1.0)
145+
- `shapes` (`object`): corner radius tokens per the Material Design 3 shape scale.
146+
- `none` · `extraSmall` · `small` · `medium` · `large` · `largeIncreased` · `extraLarge` · `extraLargeIncreased` · `extraExtraLarge` · `full`
147+
- `motion` (`object`): animation tokens: spring physics, easing curves, and durations.
148+
- `spring` - spring stiffness/damping configs for `fast`, `default`, and `slow` speeds, each with `spatial` and `effects` variants
149+
- `easing` - cubic bezier easing curves: `emphasized`, `emphasizedAccelerate`, `emphasizedDecelerate`, `standard`, `standardAccelerate`, `standardDecelerate`, `legacy`, and more
150+
- `duration` - duration milestones in ms: `short1` (50 ms) through `extraLong4`
151+
- `prefersReducedMotion` (`boolean`) - automatically set from device accessibility settings by `PaperProvider`
152+
- `elevation` (`object`): maps elevation level names to their numeric values (`level0``level5`).
153+
- `dynamic` (`boolean`, optional): `true` when Android Material You dynamic colors are active.
154+
- `roundness` (`number`): **Deprecated.** Use `theme.shapes.*` instead.
155+
- `animation` (`object`): **Deprecated.** Use `theme.motion.*` instead.
156+
- `scale` - **Deprecated.** Use `theme.motion.prefersReducedMotion` instead.
157+
158+
`PaperProvider` automatically reflects the device's "Reduce Motion" accessibility setting into `theme.motion.prefersReducedMotion` (and the legacy `theme.animation.scale`). To opt out and handle accessibility yourself, pass `accessibilityAdapters={false}` to `PaperProvider`.
154159

155160
## Extending the theme
156161

157162
Keeping your own properties in the theme is fully supported by our library:
158163

159164
```js
160165
import * as React from 'react';
161-
import {
162-
MD3LightTheme as DefaultTheme,
163-
PaperProvider,
164-
} from 'react-native-paper';
166+
import { LightTheme, PaperProvider } from 'react-native-paper';
165167
import App from './src/App';
166168

167169
const theme = {
168-
...DefaultTheme,
170+
...LightTheme,
169171
// Specify custom property
170172
myOwnProperty: true,
171173
// Specify custom property in nested object
172174
colors: {
173-
...DefaultTheme.colors,
175+
...LightTheme.colors,
174176
myOwnColor: '#BADA55',
175177
},
176178
};
@@ -187,7 +189,7 @@ export default function Main() {
187189
## Creating dynamic theme colors
188190

189191
Dynamic Color Themes allows for generating two color schemes lightScheme and darkScheme, based on the provided source color.
190-
Created schemes are following the Material Design 3 color system and covering colors structure from the Paper theme. User may generate these schemes using the following tool:
192+
Created schemes follow the Material Design 3 color system and cover the full color structure of the Paper theme. Use the tool below to generate them:
191193

192194
<DynamicColorTheme />
193195

@@ -205,14 +207,11 @@ Once we have copied the color schemes from the generated JSON above, we can use
205207

206208
```jsx
207209
import * as React from 'react';
208-
import {
209-
MD3LightTheme as DefaultTheme,
210-
PaperProvider,
211-
} from 'react-native-paper';
210+
import { LightTheme, PaperProvider } from 'react-native-paper';
212211
import App from './src/App';
213212

214213
const theme = {
215-
...DefaultTheme,
214+
...LightTheme,
216215
colors: yourGeneratedLightOrDarkScheme.colors, // Copy it from the color codes scheme and then use it here
217216
};
218217

@@ -227,12 +226,29 @@ export default function Main() {
227226

228227
### Sync dynamic colors with system colors
229228

230-
React Native Paper provides built-in support for Android dynamic colors through `DynamicLightTheme` and `DynamicDarkTheme`. These themes use React Native's `PlatformColor` API to map all Material Design 3 color roles to Android system colors, so any changes the user makes to their system palette are automatically reflected in the app.
229+
React Native Paper supports Android Material You dynamic colors (wallpaper-seeded colors). The simplest way to enable them is the `dynamicColor` prop on `PaperProvider`:
230+
231+
```tsx
232+
import { PaperProvider } from 'react-native-paper';
233+
import App from './src/App';
234+
235+
export default function Main() {
236+
return (
237+
<PaperProvider dynamicColor>
238+
<App />
239+
</PaperProvider>
240+
);
241+
}
242+
```
243+
244+
When `dynamicColor` is enabled, `PaperProvider` overlays the Android system colors onto `theme.colors` and sets `theme.dynamic = true`. On unsupported platforms and Android versions below API 31, it silently falls back to the static theme.
231245

232246
:::info
233-
Dynamic colors require Android 12 (API 31+). On older Android versions and all other platforms, these themes fall back to the default `LightTheme` / `DarkTheme`.
247+
Dynamic colors require Android 12 (API 31+). On older Android versions and all other platforms, `dynamicColor` has no effect.
234248
:::
235249

250+
Alternatively, you can use the pre-built `DynamicLightTheme` and `DynamicDarkTheme` objects directly. These use React Native's `PlatformColor` API to map all color roles to the system palette:
251+
236252
```tsx
237253
import { useColorScheme } from 'react-native';
238254
import {
@@ -255,7 +271,7 @@ export default function Main() {
255271

256272
## Adapting React Navigation theme
257273

258-
The `adaptNavigationTheme` function takes an existing React Navigation theme and returns a React Navigation theme using the colors from Material Design 3. This theme can be passed to `NavigationContainer` so that React Navigation's UI elements have the same color scheme as Paper.
274+
The `adaptNavigationTheme` function takes an existing React Navigation theme and returns a React Navigation theme using Paper's color scheme. Pass the result to `NavigationContainer` so that React Navigation's UI elements match Paper's colors.
259275

260276
```ts
261277
adaptNavigationTheme(themes);
@@ -306,21 +322,24 @@ Valid `themes` keys are:
306322

307323
```ts
308324
// App.tsx
309-
import { NavigationContainer, DefaultTheme } from '@react-navigation/native';
325+
import {
326+
NavigationContainer,
327+
DefaultTheme as NavigationDefaultTheme,
328+
} from '@react-navigation/native';
310329
import { createStackNavigator } from '@react-navigation/stack';
311330
import {
312331
PaperProvider,
313-
MD3LightTheme,
332+
LightTheme,
314333
adaptNavigationTheme,
315334
} from 'react-native-paper';
316335
const Stack = createStackNavigator();
317-
const { LightTheme } = adaptNavigationTheme({
318-
reactNavigationLight: DefaultTheme,
336+
const { LightTheme: NavigationLightTheme } = adaptNavigationTheme({
337+
reactNavigationLight: NavigationDefaultTheme,
319338
});
320339
export default function App() {
321340
return (
322-
<PaperProvider theme={MD3LightTheme}>
323-
<NavigationContainer theme={LightTheme}>
341+
<PaperProvider theme={LightTheme}>
342+
<NavigationContainer theme={NavigationLightTheme}>
324343
<Stack.Navigator initialRouteName="Home">
325344
<Stack.Screen name="Home" component={HomeScreen} />
326345
<Stack.Screen name="Details" component={DetailsScreen} />
@@ -343,29 +362,19 @@ There are two supported ways of overriding the theme:
343362
change the built-in schema shape
344363
</i>
345364

346-
:::caution
347-
TypeScript support for `withTheme` is currently limited to <b>Material You (MD3)</b> theme only.
348-
349-
<i>
350-
We are planning to provide a better support of handling custom theme overrides
351-
in future releases.
352-
</i>
353-
:::
354-
355365
### Simple built-in theme overrides
356366

357367
You can provide a `theme` prop with a theme object with the same properties as the default theme:
358368

359369
```js
360370
import * as React from 'react';
361-
import { MD3LightTheme, PaperProvider } from 'react-native-paper';
371+
import { LightTheme, PaperProvider } from 'react-native-paper';
362372
import App from './src/App';
363373

364374
const theme = {
365-
...MD3LightTheme, // or MD3DarkTheme
366-
roundness: 2,
375+
...LightTheme, // or DarkTheme
367376
colors: {
368-
...MD3LightTheme.colors,
377+
...LightTheme.colors,
369378
primary: '#3498db',
370379
secondary: '#f1c40f',
371380
tertiary: '#a1b2c3',
@@ -389,18 +398,18 @@ If you need to modify the built-in theme schema by adding a new property or chan
389398

390399
```ts
391400
import * as React from 'react';
392-
import { MD3LightTheme, PaperProvider } from 'react-native-paper';
401+
import { LightTheme, PaperProvider } from 'react-native-paper';
393402
import App from './src/App';
394403

395404
const theme = {
396-
...MD3LightTheme,
405+
...LightTheme,
397406

398407
// Specify a custom property
399408
custom: 'property',
400409

401410
// Specify a custom property in nested object
402411
colors: {
403-
...MD3LightTheme.colors,
412+
...LightTheme.colors,
404413
brandPrimary: '#fefefe',
405414
brandSecondary: 'red',
406415
},
@@ -419,18 +428,18 @@ export default function Main() {
419428

420429
```ts
421430
import * as React from 'react';
422-
import { MD3LightTheme, PaperProvider, useTheme } from 'react-native-paper';
431+
import { LightTheme, PaperProvider, useTheme } from 'react-native-paper';
423432
import App from './src/App';
424433

425434
const theme = {
426-
...MD3LightTheme,
435+
...LightTheme,
427436

428437
// Specify a custom property
429438
custom: 'property',
430439

431440
// Specify a custom property in nested object
432441
colors: {
433-
...MD3LightTheme.colors,
442+
...LightTheme.colors,
434443
brandPrimary: '#fefefe',
435444
brandSecondary: 'red',
436445
},
@@ -466,7 +475,7 @@ export default function HomeScreen() {
466475

467476
## Material Design 3
468477

469-
React Native Paper ships with Material Design 3 (Material You) only. Customize the default experience by extending `MD3LightTheme` or `MD3DarkTheme` (see [Extending the theme](#extending-the-theme) and [Advanced theme overrides](#advanced-theme-overrides)).
478+
React Native Paper implements Material Design 3 exclusively. Customize the default experience by extending `LightTheme` or `DarkTheme` (see [Extending the theme](#extending-the-theme) and [Advanced theme overrides](#advanced-theme-overrides)).
470479

471480
## Applying a theme to a paper component
472481

@@ -509,19 +518,9 @@ Now you can use your `FancyButton` component everywhere instead of using `Button
509518

510519
## Dark Theme
511520

512-
Since 3.0 we adapt dark theme to follow [Material design guidelines](https://material.io/design/color/dark-theme.html). <br/>
513-
In contrast to light theme, dark theme by default uses `surface` colour instead of `primary` on large components like `AppBar` or `BottomNavigation`.<br/>
514-
The dark theme adds a white overlay with opacity depending on elevation of surfaces. It uses it for the better accentuation of surface elevation. Using only shadow is highly imperceptible on dark surfaces.
515-
516-
We are aware that users often use dark theme in their own ways and may not want to use the default dark theme features from the guidelines.<br/>
517-
That's why if you are using dark theme you can switch between two dark theme `mode`s:
518-
519-
- `exact` where everything is like it was before. `Appbar` and `BottomNavigation` will still use primary colour by default.<br/>
520-
- `adaptive` where we follow [Material design guidelines](https://material.io/design/color/dark-theme.html), the surface will use white overlay with opacity to show elevation, `Appbar` and `BottomNavigation` will use surface colour as a background.
521-
522-
If you don't use a custom theme, Paper will automatically change between the default theme and the default dark theme, depending on device settings.
521+
React Native Paper follows the [Material Design 3 dark theme guidelines](https://m3.material.io/styles/color/dark-theme). Dark surfaces use tonal color overlays derived from the primary color to convey elevation.
523522

524-
Otherwise, your custom theme will need to handle it manually, using React Native's [Appearance API](https://reactnative.dev/docs/appearance).
523+
`PaperProvider` automatically switches between `LightTheme` and `DarkTheme` based on the device color scheme. If you pass a custom `theme` prop, it is used as-is; you can toggle dark mode by changing `theme.dark` or swapping between your own light and dark theme objects.
525524

526525
## Gotchas
527526

docs/docs/guides/04-fonts.md

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,9 @@ Now, you are able to use `fontFamily` from font files.
4747
4848
## Configuring fonts in ThemeProvider
4949
50-
:::note
51-
Older Material Design 2 platform-split font configuration (`configureFonts` with per-platform `ios` / `android` / `web` keys) is no longer supported. Use the Material Design 3 typescale and `configureFonts` as documented below.
52-
:::
53-
54-
### Material Design 3
55-
5650
#### Variants
5751
58-
In the latest version fonts in theme are structured based on the `variant` keys e.g. `displayLarge` or `bodyMedium` which are then used in `Text`'s component throughout the whole library.
52+
Fonts in the theme are structured based on `variant` keys, e.g. `displayLarge` or `bodyMedium`, which are used by `Text` throughout the library.
5953
6054
:::info
6155
The default `fontFamily` is different per particular platfrom:
@@ -317,7 +311,7 @@ If any component uses Paper's `Text` component, without specified <b>variant</b>
317311
318312
```js
319313
import * as React from 'react';
320-
import { configureFonts, MD3LightTheme, PaperProvider } from 'react-native-paper';
314+
import { configureFonts, LightTheme, PaperProvider } from 'react-native-paper';
321315
import App from './src/App';
322316

323317
const fontConfig = {
@@ -335,7 +329,7 @@ const fontConfig = {
335329
};
336330

337331
const theme = {
338-
...MD3LightTheme,
332+
...LightTheme,
339333
fonts: configureFonts({config: fontConfig}),
340334
};
341335

@@ -362,7 +356,7 @@ export const Text = customText<'customVariant'>()
362356
363357
```js
364358
import * as React from 'react';
365-
import { configureFonts, MD3LightTheme, PaperProvider } from 'react-native-paper';
359+
import { configureFonts, LightTheme, PaperProvider } from 'react-native-paper';
366360
import App from './src/App';
367361

368362
const fontConfig = {
@@ -374,7 +368,7 @@ const fontConfig = {
374368
};
375369

376370
const theme = {
377-
...MD3LightTheme,
371+
...LightTheme,
378372
fonts: configureFonts({config: fontConfig}),
379373
};
380374

@@ -391,15 +385,15 @@ export default function Main() {
391385
392386
```js
393387
import * as React from 'react';
394-
import { configureFonts, MD3LightTheme, PaperProvider } from 'react-native-paper';
388+
import { configureFonts, LightTheme, PaperProvider } from 'react-native-paper';
395389
import App from './src/App';
396390

397391
const fontConfig = {
398392
fontFamily: 'NotoSans'
399393
};
400394

401395
const theme = {
402-
...MD3LightTheme,
396+
...LightTheme,
403397
fonts: configureFonts({config: fontConfig}),
404398
};
405399

0 commit comments

Comments
 (0)