Skip to content

Commit cc1482b

Browse files
authored
Merge branch 'react-navigation:main' into patch-1
2 parents 450cd76 + 667fa29 commit cc1482b

File tree

86 files changed

+2886
-1494
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+2886
-1494
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
<!--
2+
13
# READ ME PLEASE
24
35
> **TL;DR: Make sure to add your changes to versioned docs**
@@ -7,3 +9,5 @@ Thanks for opening a PR!
79
The docs cover several versions of `react-navigation`, and in some cases there are several files (for version 1, version 2 and etc.) that all describe a single page of the docs (eg. "Getting Started").
810
911
Please make sure that the edit you're making in `docs/file-you-edited.md` is also included in the file for the correct version, eg. `/versioned_docs/version-3.x/file-you-edited.md` for version 3. If such file doesn't exist, please create it. :+1:
12+
13+
-->

.github/workflows/autofix.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
name: autofix.ci
22

33
on:
4-
push:
5-
branches:
6-
- main
74
pull_request:
85
branches:
96
- main
@@ -28,4 +25,4 @@ jobs:
2825
run: yarn prettier --write .
2926

3027
- name: Autofix
31-
uses: autofix-ci/action@8106fde54b877517c9af2c3d68918ddeaa7bed64
28+
uses: autofix-ci/action@635ffb0c9798bd160680f18fd73371e355b85f27

blog/2020-05-16-web-support.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Example:
3434

3535
```js
3636
const linking = {
37-
prefixes: ['https://mychat.com', 'mychat://'],
37+
prefixes: ['https://example.com', 'example://'],
3838
config: {
3939
screens: {
4040
Home: '',

blog/2024-03-25-introducing-static-api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ There are 2 improvements to deep linking API:
138138
return (
139139
<Navigation
140140
linking={{
141-
prefixes: ['https://mychat.com', 'mychat://'],
141+
prefixes: ['https://example.com', 'example://'],
142142
// highlight-next-line
143143
enabled: 'auto',
144144
}}
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
---
2+
title: Bottom Tabs meet Native
3+
authors: oskar
4+
tags: [tutorial]
5+
---
6+
7+
This is a guest post by Oskar Kwaśniewski, creator of `react-native-bottom-tabs`, a library exposing native tab primitives that integrates with React Navigation. If you like this guide, check out the `react-native-bottom-tabs` [documentation](https://callstackincubator.github.io/react-native-bottom-tabs/) for more!
8+
9+
This blog post will explain the differences between the JavaScript Bottom Tabs navigator and provide a step-by-step guide for integrating React Navigation with the Native Bottom Tabs Navigator.
10+
11+
<!--truncate-->
12+
13+
## Introduction
14+
15+
React Navigation comes with many navigators out of the box. We've got Stack, Native Stack, Drawer, and Bottom Tabs, but there were no Native Bottom Tabs until today!
16+
17+
Both Android and iOS have predefined native components for handling bottom navigation. For iOS it's SwiftUI's `TabView` component and for Android it's `BottomNavigationView`. The native approach gives us an appropriate appearance no matter the platform we are running on. Native Bottom Tabs is a navigator that wraps the native `TabView` and `BottomNavigationView` - so you can use them with React Navigation.
18+
19+
Let's dive into the details of this navigator.
20+
21+
Note: Native Bottom Tabs navigator is a standalone package, not released as part of React Navigation.
22+
23+
## Overview
24+
25+
You still might be wondering the difference between `@react-navigation/bottom-tabs` and `react-native-bottom-tabs`.
26+
27+
Let's go over the main differences:
28+
29+
- JS Bottom Tabs recreate the UI as closely as possible while **Native Bottom Tabs use native platform primitives** to create the tabs. This makes your tab navigation indistinguishable from Native Apps as they use the same components under the hood.
30+
- Native Bottom Tabs **adapt to interfaces of a given platform** for example: tvOS and visionOS show tabs as a sidebar on iPadOS they appear at the top, while JS Bottom Tabs are always at the bottom.
31+
32+
### Distinctive features of Native Bottom Tabs
33+
34+
#### Multi-platform support
35+
36+
Native Bottom tabs adapt to the appearance of multiple platforms. You always get natively-looking tabs!
37+
38+
<img src="/assets/blog/native-bottom-tabs/ios.png" alt="Native Tabs on iOS" />
39+
40+
Bottom Navigation on iOS, with native blur.
41+
42+
<img src="/assets/blog/native-bottom-tabs/android.png" alt="Native Tabs on Android" />
43+
44+
Bottom Navigation on Android, following Material Design 3 styling.
45+
46+
<img src="/assets/blog/native-bottom-tabs/ipados.png" alt="Native Tabs on iPadOS" />
47+
48+
On iPadOS tabs appear at the top with a button allowing you to go into the sidebar mode.
49+
50+
<img src="/assets/blog/native-bottom-tabs/visionos.png" alt="Native Tabs on visionOS" />
51+
52+
On visionOS, the tabs appear on the left side, attached outside of the window.
53+
54+
<img src="/assets/blog/native-bottom-tabs/tvos.png" alt="Native Tabs on tvOS" />
55+
56+
On tvOS tabs appear on the top, making navigation with the TV remote a breeze.
57+
58+
<img src="/assets/blog/native-bottom-tabs/macos.png" alt="Native Tabs on macOS" />
59+
60+
On macOS, tabs appear on the left side, following the design of the Finder app.
61+
62+
#### Automatic scroll to the top
63+
64+
iOS TabView automatically scrolls to the top when ScrollView is embedded inside of it.
65+
66+
#### Automatic PiP avoidance
67+
68+
The operating system recognizes navigation in your app making the Picture in Picture window automatically avoid bottom navigation.
69+
70+
#### Platform-specific styling
71+
72+
For iOS bottom navigation has a built-in blur making your app stand out. For Android, you can choose between Material 2 and Material 3 and leverage Material You system styling.
73+
74+
#### Sidebar
75+
76+
TabView can turn in to a side bar on tvOS, iPadOS and macOS. The `sidebarAdaptable` prop controls this.
77+
78+
## Getting started
79+
80+
To get started follow the installation instructions in the `react-native-bottom-tabs` [documentation](https://callstackincubator.github.io/react-native-bottom-tabs/docs/getting-started/quick-start.html).
81+
82+
Native Bottom Tabs Navigation resembles JavaScript Tabs API as closely as possible. Making your migration straightforward.
83+
84+
As mentioned before, Native Bottom Tabs use native primitives to create the tabs. This approach also has some downsides: Native components enforce certain constraints that we need to follow.
85+
86+
There are a few differences between the APIs worth noting. One of the biggest is how native tabs handle images. In JavaScript tabs, you can render React components as icons, in native tabs unfortunately it’s not possible. Instead, you have to provide one of the following options:
87+
88+
```tsx
89+
<Tab.Screen
90+
name="Albums"
91+
component={Albums}
92+
options={{
93+
tabBarIcon: () => require('person.png'),
94+
// SVG is also supported
95+
tabBarIcon: () => require('person.svg'),
96+
// or
97+
tabBarIcon: () => ({ sfSymbol: 'person' }),
98+
// You can also pass a URL
99+
tabBarIcon: () => ({ uri: 'https://example.com/icon.png' }),
100+
}}
101+
/>
102+
```
103+
104+
So if you need full customizability like providing custom tab bar icons, and advanced styling that goes beyond what’s possible with native components you should use JavaScript bottom tabs.
105+
106+
On top of that, the scope of this library doesn’t include the web so for that platform, you should use JavaScript Tabs.
107+
108+
To get started you can import `createNativeBottomTabNavigator` from `@bottom-tabs/react-navigation` and use it the same way as JavaScript Bottom Tabs.
109+
110+
### Example usage
111+
112+
```tsx
113+
import { createNativeBottomTabNavigator } from '@bottom-tabs/react-navigation';
114+
115+
const Tabs = createNativeBottomTabNavigator();
116+
117+
function NativeBottomTabs() {
118+
return (
119+
<Tabs.Navigator>
120+
<Tabs.Screen
121+
name="index"
122+
options={{
123+
title: 'Home',
124+
tabBarIcon: () => ({ uri: 'https://example.com/icon.png' }),
125+
}}
126+
/>
127+
<Tabs.Screen
128+
name="explore"
129+
options={{
130+
title: 'Explore',
131+
tabBarIcon: () => ({ uri: 'https://example.com/icon.png' }),
132+
}}
133+
/>
134+
</Tabs.Navigator>
135+
);
136+
}
137+
```
138+
139+
<img src="/assets/blog/native-bottom-tabs/result.png" alt="Native Tabs" />
140+
141+
You can check out the project [here](https://github.com/callstackincubator/react-native-bottom-tabs).
142+
143+
Thanks for reading!

blog/authors.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,11 @@ dawid:
3939
socials:
4040
x: trensik
4141
github: Trancever
42+
43+
oskar:
44+
name: Oskar Kwaśniewski
45+
image_url: https://avatars.githubusercontent.com/u/52801365
46+
title: Callstack
47+
socials:
48+
x: o_kwasniewski
49+
github: okwasniewsk

src/css/custom.css

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,12 @@
8181

8282
--ifm-footer-padding-horizontal: var(--ifm-spacing-horizontal);
8383
--ifm-footer-padding-vertical: var(--ifm-spacing-vertical);
84-
--ifm-tabs-padding-vertical: 0.5rem;
84+
--ifm-tabs-padding-vertical: 0.375rem;
85+
86+
--ifm-alert-shadow: none;
8587
--ifm-alert-border-left-width: 0;
88+
89+
--codeblock-background-color: #f6f8fa;
8690
}
8791

8892
:root[data-theme='dark'] {
@@ -133,6 +137,8 @@
133137
--ifm-home-color-border: #f7f7ff;
134138

135139
--docusaurus-highlighted-code-line-bg: rgba(255, 255, 255, 0.07);
140+
141+
--codeblock-background-color: #282a35;
136142
}
137143

138144
h1 {
@@ -388,15 +394,37 @@ p {
388394
}
389395

390396
.tabs__item {
391-
border-bottom: 1px solid var(--ifm-toc-border-color);
397+
border-bottom: 2px solid var(--ifm-toc-border-color);
392398
border-bottom-left-radius: 0;
393399
border-bottom-right-radius: 0;
394400
}
395401

396402
.tabs__item--active,
397403
.tabs__item--active:hover {
398404
border-bottom-color: var(--ifm-tabs-color-active-border);
399-
background-color: var(--ifm-menu-color-background-active);
405+
}
406+
407+
.tabs-container:has(
408+
> .margin-top--md > [role='tabpanel'] > .theme-code-block:only-child
409+
):not(:has(> .margin-top--md > [role='tabpanel'] > :nth-child(2))) {
410+
background-color: var(--codeblock-background-color);
411+
border-radius: var(--ifm-code-border-radius);
412+
413+
& > .margin-top--md {
414+
margin-top: 0 !important;
415+
}
416+
417+
& > .tabs {
418+
box-shadow: inset 0 -2px 0 var(--ifm-toc-border-color);
419+
}
420+
421+
& > .tabs > .tabs__item {
422+
border-top-right-radius: 0;
423+
}
424+
425+
& > .tabs > .tabs__item:not(:first-child) {
426+
border-top-left-radius: 0;
427+
}
400428
}
401429

402430
.col:has(.table-of-contents) {
@@ -475,6 +503,10 @@ samp {
475503
display: none;
476504
}
477505

506+
.theme-code-block {
507+
box-shadow: none !important;
508+
}
509+
478510
.theme-code-block:has(+ .snack-sample-link) {
479511
margin-bottom: 0;
480512
border-bottom-left-radius: 0;
@@ -488,17 +520,15 @@ samp {
488520
margin-top: 0;
489521
margin-bottom: var(--ifm-leading);
490522
padding: calc(var(--ifm-pre-padding) / 2) var(--ifm-pre-padding);
491-
background-color: #f6f8fa;
523+
background-color: var(--codeblock-background-color);
492524
border-top-width: 1px;
493525
border-top-style: solid;
494526
border-top-color: var(--ifm-color-gray-200);
495527
border-bottom-left-radius: var(--ifm-pre-border-radius);
496528
border-bottom-right-radius: var(--ifm-pre-border-radius);
497-
box-shadow: var(--ifm-global-shadow-lw);
498529
}
499530

500531
[data-theme='dark'] .theme-code-block + .snack-sample-link {
501-
background-color: #282a35;
502532
border-top-color: rgba(255, 255, 255, 0.07);
503533
}
504534

0 commit comments

Comments
 (0)