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
[docs] Update Appearance API docs, add Mermaid diagram support
Update the `Appearance` and `useColorScheme` API reference pages with clearer descriptions, consistent terminology ("color scheme" over "user interface style"), and aligned return value docs between the two pages.
Adds `@docusaurus/theme-mermaid`, and includes a Mermaid flowchart on the Appearance page illustrating the `setColorScheme` override behaviour.
Copy file name to clipboardExpand all lines: docs/appearance.md
+37-23Lines changed: 37 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import con
9
9
import {Appearance} from'react-native';
10
10
```
11
11
12
-
The `Appearance` module exposes information about the user's appearance preferences, such as their preferred color scheme (light or dark).
12
+
The `Appearance` module exposes information about the user's appearance preferences, such as their preferred system color scheme (light or dark).
13
13
14
14
#### Developer notes
15
15
@@ -53,7 +53,26 @@ if (colorScheme === 'dark') {
53
53
}
54
54
```
55
55
56
-
Although the color scheme is available immediately, this may change (e.g. scheduled color scheme change at sunrise or sunset). Any rendering logic or styles that depend on the user preferred color scheme should try to call this function on every render, rather than caching the value. For example, you may use the [`useColorScheme`](usecolorscheme) React hook as it provides and subscribes to color scheme updates, or you may use inline styles rather than setting a value in a `StyleSheet`.
56
+
Although the color scheme is available immediately, this may change when not overridden via `setColorScheme()` (e.g. scheduled color scheme change at sunrise or sunset). Any rendering logic or styles that depend on the user preferred color scheme should try to call this function on every render, rather than caching the value.
57
+
58
+
**Recommended:** Use the [`useColorScheme`](usecolorscheme) hook.
59
+
60
+
### App-level overriding
61
+
62
+
`setColorScheme()` overrides the color scheme at the application level — it does not affect the system setting or other applications. Passing `'unspecified'` removes any override, restoring the system preference.
Indicates the current user preferred color scheme. The value may be updated later, either through direct user action (e.g. theme selection in device settings or application-level selected user interface style via `setColorScheme`) or on a schedule (e.g. light and dark themes that follow the day/night cycle).
89
+
Returns the active color scheme. The value may be updated later, either through direct user action (e.g. theme selection in device settings or application-level selected user interface style via `setColorScheme`) or on a schedule (e.g. light and dark themes that follow the day/night cycle).
71
90
72
-
Supported color schemes:
91
+
Return values:
73
92
74
-
-`'light'`: The user prefers a light color theme.
75
-
-`'dark'`: The user prefers a dark color theme.
76
-
-`null`: The user has not indicated a preferred color theme.
Force the application to always adopt a light or dark interface style. The default value is `null` which causes the application to inherit the system's interface style. If you assign a different value, the new style applies to the application and all native elements within the application (Alerts, Pickers etc).
108
+
Forces the application to always adopt a light or dark interface style. The change applies to the application and all native elements within it (Alerts, Pickers, etc.).
93
109
94
-
Supported color schemes:
110
+
This is an app-level override — it does not affect the system's selected interface style or any style set in other applications.
95
111
96
-
-`light`: Apply light user interface style.
97
-
-`dark`: Apply dark user interface style.
98
-
- null: Follow the system's interface style.
112
+
Supported values:
99
113
100
-
:::note
101
-
The change will not affect the system's selected interface style or any style set in other applications.
102
-
:::
114
+
-`'light'`: Apply light color scheme.
115
+
-`'dark'`: Apply dark color scheme.
116
+
-`'unspecified'`: Follow the system color scheme (removes any override).
103
117
104
118
---
105
119
@@ -111,4 +125,4 @@ static addChangeListener(
111
125
): NativeEventSubscription;
112
126
```
113
127
114
-
Add an event handler that is fired when appearance preferences change.
128
+
Add an event handler that is fired when appearance preferences change. On iOS and Android, the `colorScheme` value in the callback is always `'light'` or `'dark'`.
Copy file name to clipboardExpand all lines: docs/usecolorscheme.md
+6-5Lines changed: 6 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,13 +7,14 @@ title: useColorScheme
7
7
import {useColorScheme} from'react-native';
8
8
```
9
9
10
-
The `useColorScheme` React hook provides and subscribes to color scheme updates from the [`Appearance`](appearance) module. The return value indicates the current user preferred color scheme. The value may be updated later, either through direct user action (e.g. theme selection in device settings) or on a schedule (e.g. light and dark themes that follow the day/night cycle).
10
+
The `useColorScheme` React hook provides and subscribes to color scheme updates from the [`Appearance`](appearance) module. The return value indicates the active color scheme. The value may be updated later, either through direct user action (e.g. theme selection in device settings or application-level selected user interface style via [`setColorScheme`](appearance#setcolorscheme)) or on a schedule (e.g. light and dark themes that follow the day/night cycle).
11
11
12
-
### Supported color schemes
12
+
### Return values
13
13
14
-
-`"light"`: The user prefers a light color theme.
15
-
-`"dark"`: The user prefers a dark color theme.
16
-
-`null`: The user has not indicated a preferred color theme.
Copy file name to clipboardExpand all lines: website/versioned_docs/version-0.85/appearance.md
+37-23Lines changed: 37 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import con
9
9
import {Appearance} from'react-native';
10
10
```
11
11
12
-
The `Appearance` module exposes information about the user's appearance preferences, such as their preferred color scheme (light or dark).
12
+
The `Appearance` module exposes information about the user's appearance preferences, such as their preferred system color scheme (light or dark).
13
13
14
14
#### Developer notes
15
15
@@ -53,7 +53,26 @@ if (colorScheme === 'dark') {
53
53
}
54
54
```
55
55
56
-
Although the color scheme is available immediately, this may change (e.g. scheduled color scheme change at sunrise or sunset). Any rendering logic or styles that depend on the user preferred color scheme should try to call this function on every render, rather than caching the value. For example, you may use the [`useColorScheme`](usecolorscheme) React hook as it provides and subscribes to color scheme updates, or you may use inline styles rather than setting a value in a `StyleSheet`.
56
+
Although the color scheme is available immediately, this may change when not overridden via `setColorScheme()` (e.g. scheduled color scheme change at sunrise or sunset). Any rendering logic or styles that depend on the user preferred color scheme should try to call this function on every render, rather than caching the value.
57
+
58
+
**Recommended:** Use the [`useColorScheme`](usecolorscheme) hook.
59
+
60
+
### App-level overriding
61
+
62
+
`setColorScheme()` overrides the color scheme at the application level — it does not affect the system setting or other applications. Passing `'unspecified'` removes any override, restoring the system preference.
Indicates the current user preferred color scheme. The value may be updated later, either through direct user action (e.g. theme selection in device settings or application-level selected user interface style via `setColorScheme`) or on a schedule (e.g. light and dark themes that follow the day/night cycle).
89
+
Returns the active color scheme. The value may be updated later, either through direct user action (e.g. theme selection in device settings or application-level selected user interface style via `setColorScheme`) or on a schedule (e.g. light and dark themes that follow the day/night cycle).
71
90
72
-
Supported color schemes:
91
+
Return values:
73
92
74
-
-`'light'`: The user prefers a light color theme.
75
-
-`'dark'`: The user prefers a dark color theme.
76
-
-`null`: The user has not indicated a preferred color theme.
Force the application to always adopt a light or dark interface style. The default value is `null` which causes the application to inherit the system's interface style. If you assign a different value, the new style applies to the application and all native elements within the application (Alerts, Pickers etc).
108
+
Forces the application to always adopt a light or dark interface style. The change applies to the application and all native elements within it (Alerts, Pickers, etc.).
93
109
94
-
Supported color schemes:
110
+
This is an app-level override — it does not affect the system's selected interface style or any style set in other applications.
95
111
96
-
-`light`: Apply light user interface style.
97
-
-`dark`: Apply dark user interface style.
98
-
- null: Follow the system's interface style.
112
+
Supported values:
99
113
100
-
:::note
101
-
The change will not affect the system's selected interface style or any style set in other applications.
102
-
:::
114
+
-`'light'`: Apply light color scheme.
115
+
-`'dark'`: Apply dark color scheme.
116
+
-`'unspecified'`: Follow the system color scheme (removes any override).
103
117
104
118
---
105
119
@@ -111,4 +125,4 @@ static addChangeListener(
111
125
): NativeEventSubscription;
112
126
```
113
127
114
-
Add an event handler that is fired when appearance preferences change.
128
+
Add an event handler that is fired when appearance preferences change. On iOS and Android, the `colorScheme` value in the callback is always `'light'` or `'dark'`.
Copy file name to clipboardExpand all lines: website/versioned_docs/version-0.85/usecolorscheme.md
+6-5Lines changed: 6 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,13 +7,14 @@ title: useColorScheme
7
7
import {useColorScheme} from'react-native';
8
8
```
9
9
10
-
The `useColorScheme` React hook provides and subscribes to color scheme updates from the [`Appearance`](appearance) module. The return value indicates the current user preferred color scheme. The value may be updated later, either through direct user action (e.g. theme selection in device settings) or on a schedule (e.g. light and dark themes that follow the day/night cycle).
10
+
The `useColorScheme` React hook provides and subscribes to color scheme updates from the [`Appearance`](appearance) module. The return value indicates the active color scheme. The value may be updated later, either through direct user action (e.g. theme selection in device settings or application-level selected user interface style via [`setColorScheme`](appearance#setcolorscheme)) or on a schedule (e.g. light and dark themes that follow the day/night cycle).
11
11
12
-
### Supported color schemes
12
+
### Return values
13
13
14
-
-`"light"`: The user prefers a light color theme.
15
-
-`"dark"`: The user prefers a dark color theme.
16
-
-`null`: The user has not indicated a preferred color theme.
0 commit comments