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/how-to/view-transitions.md
+28-4Lines changed: 28 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,13 +20,37 @@ The simplest way to enable view transitions is by adding the `viewTransition` pr
20
20
21
21
Without any additional CSS, this provides a basic cross-fade animation between pages.
22
22
23
+
### 2. Enable view transitions with programmatic navigation
24
+
25
+
When using programmatic navigation with the `useNavigate` hook, you can enable view transitions by passing the `viewTransition: true` option:
26
+
27
+
```tsx
28
+
import { useNavigate } from"react-router";
29
+
30
+
function NavigationButton() {
31
+
const navigate =useNavigate();
32
+
33
+
return (
34
+
<button
35
+
onClick={() =>
36
+
navigate("/about", { viewTransition: true })
37
+
}
38
+
>
39
+
About
40
+
</button>
41
+
);
42
+
}
43
+
```
44
+
45
+
This provides the same cross-fade animation as using the `viewTransition` prop on Link components.
46
+
23
47
For more information on using the View Transitions API, please refer to the ["Smooth transitions with the View Transition API" guide][view-transitions-guide] from the Google Chrome team.
24
48
25
49
## Image Gallery Example
26
50
27
51
Let's build an image gallery that demonstrates how to trigger and use view transitions. We'll create a list of images that expand into a detail view with smooth animations.
28
52
29
-
### 2. Create the image gallery route
53
+
### 1. Create the image gallery route
30
54
31
55
```tsx filename=routes/image-gallery.tsx
32
56
import { NavLink } from"react-router";
@@ -62,7 +86,7 @@ export default function ImageGalleryRoute() {
62
86
}
63
87
```
64
88
65
-
### 3. Add transition styles
89
+
### 2. Add transition styles
66
90
67
91
Define view transition names and animations for elements that should transition smoothly between routes.
68
92
@@ -98,7 +122,7 @@ Define view transition names and animations for elements that should transition
98
122
}
99
123
```
100
124
101
-
### 4. Create the image detail route
125
+
### 3. Create the image detail route
102
126
103
127
The detail view needs to use the same view transition names to create a seamless animation.
104
128
@@ -122,7 +146,7 @@ export default function ImageDetailsRoute({
122
146
}
123
147
```
124
148
125
-
### 5. Add matching transition styles for the detail view
149
+
### 4. Add matching transition styles for the detail view
Copy file name to clipboardExpand all lines: docs/start/data/custom.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ order: 8
9
9
10
10
## Introduction
11
11
12
-
Instead of using `@react-router/dev`, you can integrate React Router's framework features (like loaders, actions, fetchers, etc.) into your own bundler and server abstractions with Data Mode..
12
+
Instead of using `@react-router/dev`, you can integrate React Router's framework features (like loaders, actions, fetchers, etc.) into your own bundler and server abstractions with Data Mode.
Copy file name to clipboardExpand all lines: docs/tutorials/address-book.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -688,7 +688,7 @@ export default function SidebarLayout() {
688
688
689
689
👉 **Move route definitions under the sidebar layout**
690
690
691
-
We can define a `layout` route to automatically render the sidebar for all matched routes within in. This is basically what our `root` was, but now we can scope it to specific routes.
691
+
We can define a `layout` route to automatically render the sidebar for all matched routes within it. This is basically what our `root` was, but now we can scope it to specific routes.
0 commit comments