You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: versioned_docs/version-8.x/themes.md
+46-33Lines changed: 46 additions & 33 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -231,12 +231,12 @@ A theme is a JS object containing a list of colors to use. It contains the follo
231
231
232
232
-`dark` (`boolean`): Whether this is a dark theme or a light theme
233
233
-`colors` (`object`): Various colors used by react navigation components:
234
-
-`primary` (`string`): The primary color of the app used to tint various elements. Usually you'll want to use your brand color for this.
235
-
-`background` (`string`): The color of various backgrounds, such as the background color for the screens.
236
-
-`card` (`string`): The background color of card-like elements, such as headers, tab bars etc.
237
-
-`text` (`string`): The text color of various elements.
238
-
-`border` (`string`): The color of borders, e.g. header border, tab bar border etc.
239
-
-`notification` (`string`): The color of notifications and badge (e.g. badge in bottom tabs).
234
+
-`primary` (`ColorValue`): The primary color of the app used to tint various elements. Usually you'll want to use your brand color for this.
235
+
-`background` (`ColorValue`): The color of various backgrounds, such as the background color for the screens.
236
+
-`card` (`ColorValue`): The background color of card-like elements, such as headers, tab bars etc.
237
+
-`text` (`ColorValue`): The text color of various elements.
238
+
-`border` (`ColorValue`): The color of borders, e.g. header border, tab bar border etc.
239
+
-`notification` (`ColorValue`): The color of notifications and badge (e.g. badge in bottom tabs).
240
240
-`fonts` (`object`): Various fonts used by react navigation components:
241
241
-`regular` (`object`): Style object for the primary font used in the app.
242
242
-`medium` (`object`): Style object for the semi-bold variant of the primary font.
@@ -325,7 +325,32 @@ const MyTheme = {
325
325
};
326
326
```
327
327
328
-
Providing a theme will take care of styling of all the official navigators. React Navigation also provides several tools to help you make your customizations of those navigators and the screens within the navigators can use the theme too.
328
+
Providing a theme will take care of styling of all the official navigators.
329
+
330
+
## Built-in themes
331
+
332
+
React Navigation provides basic light and dark themes:
333
+
334
+
-`DefaultTheme`
335
+
-`DarkTheme`
336
+
337
+
On Android, it also provides themes based on Material Design:
338
+
339
+
-`MaterialLightTheme`
340
+
-`MaterialDarkTheme`
341
+
342
+
The Material themes use platform colors to provide dynamic colors that adapt to the user's wallpaper and theme preferences.
343
+
344
+
You can import the themes from the `@react-navigation/native` package:
345
+
346
+
```js
347
+
import {
348
+
DefaultTheme,
349
+
DarkTheme,
350
+
MaterialLightTheme,
351
+
MaterialDarkTheme,
352
+
} from'@react-navigation/native';
353
+
```
329
354
330
355
## Using platform colors
331
356
@@ -340,47 +365,35 @@ import { DefaultTheme } from '@react-navigation/native';
This allows your app's navigation UI to automatically adapt to system theme changes and use native colors.
367
390
368
-
:::note
391
+
:::info
369
392
370
-
When using dynamic colors like `PlatformColor` or `DynamicColorIOS`, React Navigation cannot automatically adjust colors in some scenarios (e.g., adjusting the text color based on background color). In these cases, it will fall back to pre-defined colors according to the theme.
393
+
When using dynamic colors like `PlatformColor` or `DynamicColorIOS`, React Navigation cannot automatically adjust colors in some scenarios (e.g., adjusting the text color based on background color). In these cases, it will fall back to pre-defined colors. You may need to pass appropriate colors for such components if needed via options.
371
394
372
395
:::
373
396
374
-
## Built-in themes
375
-
376
-
As operating systems add built-in support for light and dark modes, supporting dark mode is less about keeping hip to trends and more about conforming to the average user expectations for how apps should work. In order to provide support for light and dark mode in a way that is reasonably consistent with the OS defaults, these themes are built in to React Navigation.
377
-
378
-
You can import the default and dark themes like so:
If you're changing the theme in the app, native UI elements such as Alert, ActionSheet etc. won't reflect the new theme. You can do the following to keep the native theme in sync:
Copy file name to clipboardExpand all lines: versioned_docs/version-8.x/upgrading-from-7.x.md
+11Lines changed: 11 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -955,6 +955,17 @@ export default function TabViewExample() {
955
955
956
956
You can also create your own custom adapter by implementing the required interface. See the [`react-native-tab-view` docs](tab-view.md) for more information.
957
957
958
+
### New built-in themes base on Material Design are now available
959
+
960
+
The `@react-navigation/native` package now exports 2 new built-in themes based on Material Design:
961
+
962
+
-`MaterialLightTheme`
963
+
-`MaterialDarkTheme`
964
+
965
+
These themes use platform colors to provide dynamic colors that adapt to the user's wallpaper and theme preferences.
966
+
967
+
See [Themes](themes.md#built-in-themes) for more details.
968
+
958
969
### `useLogger` devtools now shows more information
959
970
960
971
Previously, the `useLogger` devtools only showed navigation actions. It now shows the following additional information:
0 commit comments