Skip to content

Commit 7917e93

Browse files
committed
Update theming docs
1 parent 2129b35 commit 7917e93

File tree

1 file changed

+75
-4
lines changed

1 file changed

+75
-4
lines changed

versioned_docs/version-7.x/themes.md

Lines changed: 75 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ title: Themes
44
sidebar_label: Themes
55
---
66

7-
Themes allow you to change the colors of various components provided by React Navigation. You can use themes to:
7+
Themes allow you to change the colors and fonts of various components provided by React Navigation. You can use themes to:
88

9-
- Customize the colors match your brand
9+
- Customize the colors and fonts to match your brand
1010
- Provide light and dark themes based on the time of the day or user preference
1111

1212
## Basic usage
@@ -36,22 +36,37 @@ export default function App() {
3636

3737
You can change the theme prop dynamically and all the components will automatically update to reflect the new theme. If you haven't provided a `theme` prop, the default theme will be used.
3838

39+
## Properties
40+
3941
A theme is a JS object containing a list of colors to use. It contains the following properties:
4042

4143
- `dark` (`boolean`): Whether this is a dark theme or a light theme
4244
- `colors` (`object`): Various colors used by react navigation components:
4345
- `primary` (`string`): The primary color of the app used to tint various elements. Usually you'll want to use your brand color for this.
44-
- `background` (`string`): The color of various backgrounds, such as background color for the screens.
46+
- `background` (`string`): The color of various backgrounds, such as the background color for the screens.
4547
- `card` (`string`): The background color of card-like elements, such as headers, tab bars etc.
4648
- `text` (`string`): The text color of various elements.
4749
- `border` (`string`): The color of borders, e.g. header border, tab bar border etc.
48-
- `notification` (`string`): The color of Tab Navigator badge.
50+
- `notification` (`string`): The color of notifications and badge (e.g. badge in bottom tabs).
51+
- `fonts` (`object`): Various fonts used by react navigation components:
52+
- `regular` (`object`): Style object for the primary font used in the app.
53+
- `medium` (`object`): Style object for the semi-bold variant of the primary font.
54+
- `bold` (`object`): Style object for the bold variant of the primary font.
55+
- `heavy` (`object`): Style object for the extra-bold variant of the primary font.
56+
57+
The style objects for fonts contain the following properties:
58+
59+
- `fontFamily` (`string`): The name of the font family (or font stack on Web) to use, e.g. `Roboto` or `Helvetica Neue`. The system fonts are used by default.
60+
- `fontWeight` (`string`): The font weight to use. Valid values are `normal`, `bold`, `100`, `200`, `300`, `400`, `500`, `600`, `700`, `800`, `900`.
4961

5062
When creating a custom theme, you will need to provide all of these properties.
5163

5264
Example theme:
5365

5466
```js
67+
const WEB_FONT_STACK =
68+
'system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"';
69+
5570
const MyTheme = {
5671
dark: false,
5772
colors: {
@@ -62,6 +77,62 @@ const MyTheme = {
6277
border: 'rgb(199, 199, 204)',
6378
notification: 'rgb(255, 69, 58)',
6479
},
80+
fonts: Platform.select({
81+
web: {
82+
regular: {
83+
fontFamily: WEB_FONT_STACK,
84+
fontWeight: '400',
85+
},
86+
medium: {
87+
fontFamily: WEB_FONT_STACK,
88+
fontWeight: '500',
89+
},
90+
bold: {
91+
fontFamily: WEB_FONT_STACK,
92+
fontWeight: '600',
93+
},
94+
heavy: {
95+
fontFamily: WEB_FONT_STACK,
96+
fontWeight: '700',
97+
},
98+
},
99+
ios: {
100+
regular: {
101+
fontFamily: 'System',
102+
fontWeight: '400',
103+
},
104+
medium: {
105+
fontFamily: 'System',
106+
fontWeight: '500',
107+
},
108+
bold: {
109+
fontFamily: 'System',
110+
fontWeight: '600',
111+
},
112+
heavy: {
113+
fontFamily: 'System',
114+
fontWeight: '700',
115+
},
116+
},
117+
default: {
118+
regular: {
119+
fontFamily: 'sans-serif',
120+
fontWeight: 'normal',
121+
},
122+
medium: {
123+
fontFamily: 'sans-serif-medium',
124+
fontWeight: 'normal',
125+
},
126+
bold: {
127+
fontFamily: 'sans-serif',
128+
fontWeight: '600',
129+
},
130+
heavy: {
131+
fontFamily: 'sans-serif',
132+
fontWeight: '700',
133+
},
134+
},
135+
}),
65136
};
66137
```
67138

0 commit comments

Comments
 (0)