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: docs/themes.md
+30-1Lines changed: 30 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ Providing a light theme and a dark theme is a nice way to let your users adjust
8
8
9
9
# Built-in themes
10
10
11
-
> Note: support for built-in themes requires react-navigation@>=3.12.0-alpha! There is not a stable release with support for this yet. Skip ahead to "Custom themes using React context" if you'd like to learn more about how you can use themes today on a stable release.
11
+
> Note: support for built-in themes requires react-navigation@>=3.12.0!
12
12
13
13
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. You can pass in a `theme` prop to your app container component in order to switch between light and dark mode, and the value of that `theme` prop can come from whichever API you use to detect user preferences for dark mode, or in the case of older operating system versions, from a custom configuration within your app UI.
This will take care of styling the stack navigator, bottom tab navigator, and drawer navigator for you. React Navigation also provides several tools to help you make your customizations of those navigators and the screens within the navigators support both themes too.
23
23
24
+
## Using the operating system preferences
25
+
26
+
At the time of writing, `react-native` does not currently support detecting the operating system color scheme preferences in the core ([you can follow this pull request](https://github.com/facebook/react-native/pull/26172)). Until it is part of core and you have updated to the version that includes it, you can use `react-native-appearance`.
27
+
28
+
> Note: if you use the Expo managed workflow, this requires SDK 35+
29
+
30
+
First, you need to install `react-native-appearance`. [Follow the instructions in the README](https://github.com/expo/react-native-appearance).
31
+
32
+
Once you've installed it, set your root component up as follows:
If the version of React Native you are using doesn't support hooks yet, you can use the `Appearance.addChangeListener(cb)` and `Appearance.getColorScheme()` functions as described in the [usage section of the README](https://github.com/expo/react-native-appearance#usage).
52
+
24
53
## Using the currently selected theme
25
54
26
55
Two tools are available to gain access to the theme in any component that descends from the app navigation container: `useTheme` and `ThemeConext`.
Copy file name to clipboardExpand all lines: website/versioned_docs/version-3.x/themes.md
+30-1Lines changed: 30 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ Providing a light theme and a dark theme is a nice way to let your users adjust
9
9
10
10
# Built-in themes
11
11
12
-
> Note: support for built-in themes requires react-navigation@>=3.12.0-alpha! There is not a stable release with support for this yet. Skip ahead to "Custom themes using React context" if you'd like to learn more about how you can use themes today on a stable release.
12
+
> Note: support for built-in themes requires react-navigation@>=3.12.0!
13
13
14
14
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. You can pass in a `theme` prop to your app container component in order to switch between light and dark mode, and the value of that `theme` prop can come from whichever API you use to detect user preferences for dark mode, or in the case of older operating system versions, from a custom configuration within your app UI.
This will take care of styling the stack navigator, bottom tab navigator, and drawer navigator for you. React Navigation also provides several tools to help you make your customizations of those navigators and the screens within the navigators support both themes too.
24
24
25
+
## Using the operating system preferences
26
+
27
+
At the time of writing, `react-native` does not currently support detecting the operating system color scheme preferences in the core ([you can follow this pull request](https://github.com/facebook/react-native/pull/26172)). Until it is part of core and you have updated to the version that includes it, you can use `react-native-appearance`.
28
+
29
+
> Note: if you use the Expo managed workflow, this requires SDK 35+
30
+
31
+
First, you need to install `react-native-appearance`. [Follow the instructions in the README](https://github.com/expo/react-native-appearance).
32
+
33
+
Once you've installed it, set your root component up as follows:
If the version of React Native you are using doesn't support hooks yet, you can use the `Appearance.addChangeListener(cb)` and `Appearance.getColorScheme()` functions as described in the [usage section of the README](https://github.com/expo/react-native-appearance#usage).
53
+
25
54
## Using the currently selected theme
26
55
27
56
Two tools are available to gain access to the theme in any component that descends from the app navigation container: `useTheme` and `ThemeConext`.
0 commit comments