1e41f4b71Sopenharmony_ci# Navigation Transition
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci
4e41f4b71Sopenharmony_ciNavigation transition is a transition animation that runs during the navigation from one view to another. You can customize the animation settings of the navigation transition. For details, see [Navigation Example 3](../reference/apis-arkui/arkui-ts/ts-basic-components-navigation.md#example-3).
5e41f4b71Sopenharmony_ci
6e41f4b71Sopenharmony_ci
7e41f4b71Sopenharmony_ciTo implement the navigation transition, you are advised to use the [Navigation](../reference/apis-arkui/arkui-ts/ts-basic-components-navigation.md) component, complete with the [NavDestination](../reference/apis-arkui/arkui-ts/ts-basic-components-navdestination.md) component.
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ciBelow is the complete sample code and effect.
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ci## Creating a Navigation Page
13e41f4b71Sopenharmony_ciTo create a navigation page:
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_ci1. Use **Navigation** to create a navigation home page and create a **NavPathStack** as the navigation stack to enable transitions between different pages.
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ci2. Add a **List** component to **Navigation** to define the different level-1 pages on the navigation home page.
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci3. Add an **onClick** method to the component inside the **List**, and use the **pushPathByName** method of the **NavPathStack** within it. This allows the component to transition from the current page to the page corresponding to the input parameter **name** in the routing table upon click.
20e41f4b71Sopenharmony_ci```ts
21e41f4b71Sopenharmony_ci//PageOne.ets
22e41f4b71Sopenharmony_ci@Entry
23e41f4b71Sopenharmony_ci@Component
24e41f4b71Sopenharmony_cistruct NavigationDemo {
25e41f4b71Sopenharmony_ci  @Provide('pathInfos') pathInfos: NavPathStack = new NavPathStack();
26e41f4b71Sopenharmony_ci  private listArray: Array<string> = ['WLAN', 'Bluetooth', 'Personal Hotpot', 'Connect & Share'];
27e41f4b71Sopenharmony_ci
28e41f4b71Sopenharmony_ci  build() {
29e41f4b71Sopenharmony_ci    Column() {
30e41f4b71Sopenharmony_ci      Navigation(this.pathInfos) {
31e41f4b71Sopenharmony_ci        TextInput({ placeholder: 'Search by keyword' })
32e41f4b71Sopenharmony_ci          .width('90%')
33e41f4b71Sopenharmony_ci          .height(40)
34e41f4b71Sopenharmony_ci          .margin({ bottom: 10 })
35e41f4b71Sopenharmony_ci
36e41f4b71Sopenharmony_ci        // Define the level-1 navigation view through List.
37e41f4b71Sopenharmony_ci        List({ space: 12, initialIndex: 0 }) {
38e41f4b71Sopenharmony_ci          ForEach(this.listArray, (item: string) => {
39e41f4b71Sopenharmony_ci            ListItem() {
40e41f4b71Sopenharmony_ci              Row() {
41e41f4b71Sopenharmony_ci                Row() {
42e41f4b71Sopenharmony_ci                  Text(`${item.slice(0, 1)}`)
43e41f4b71Sopenharmony_ci                    .fontColor(Color.White)
44e41f4b71Sopenharmony_ci                    .fontSize(14)
45e41f4b71Sopenharmony_ci                    .fontWeight(FontWeight.Bold)
46e41f4b71Sopenharmony_ci                }
47e41f4b71Sopenharmony_ci                .width(30)
48e41f4b71Sopenharmony_ci                .height(30)
49e41f4b71Sopenharmony_ci                .backgroundColor('#a8a8a8')
50e41f4b71Sopenharmony_ci                .margin({ right: 20 })
51e41f4b71Sopenharmony_ci                .borderRadius(20)
52e41f4b71Sopenharmony_ci                .justifyContent(FlexAlign.Center)
53e41f4b71Sopenharmony_ci
54e41f4b71Sopenharmony_ci                Column() {
55e41f4b71Sopenharmony_ci                  Text(item)
56e41f4b71Sopenharmony_ci                    .fontSize(16)
57e41f4b71Sopenharmony_ci                    .margin({ bottom: 5 })
58e41f4b71Sopenharmony_ci                }
59e41f4b71Sopenharmony_ci                .alignItems(HorizontalAlign.Start)
60e41f4b71Sopenharmony_ci
61e41f4b71Sopenharmony_ci                Blank()
62e41f4b71Sopenharmony_ci
63e41f4b71Sopenharmony_ci                Row()
64e41f4b71Sopenharmony_ci                  .width(12)
65e41f4b71Sopenharmony_ci                  .height(12)
66e41f4b71Sopenharmony_ci                  .margin({ right: 15 })
67e41f4b71Sopenharmony_ci                  .border({
68e41f4b71Sopenharmony_ci                    width: { top: 2, right: 2 },
69e41f4b71Sopenharmony_ci                    color: 0xcccccc
70e41f4b71Sopenharmony_ci                  })
71e41f4b71Sopenharmony_ci                  .rotate({ angle: 45 })
72e41f4b71Sopenharmony_ci              }
73e41f4b71Sopenharmony_ci              .borderRadius(15)
74e41f4b71Sopenharmony_ci              .shadow({ radius: 100, color: '#ededed' })
75e41f4b71Sopenharmony_ci              .width('90%')
76e41f4b71Sopenharmony_ci              .alignItems(VerticalAlign.Center)
77e41f4b71Sopenharmony_ci              .padding({ left: 15, top: 15, bottom: 15 })
78e41f4b71Sopenharmony_ci              .backgroundColor(Color.White)
79e41f4b71Sopenharmony_ci            }
80e41f4b71Sopenharmony_ci            .width('100%')
81e41f4b71Sopenharmony_ci            .onClick(() => {
82e41f4b71Sopenharmony_ci              this.pathInfos.pushPathByName(`${item}`, 'Details page parameters')// Push the navigation destination page specified by name, with the data specified by param, to the navigation stack.
83e41f4b71Sopenharmony_ci            })
84e41f4b71Sopenharmony_ci          }, (item: string): string => item)
85e41f4b71Sopenharmony_ci        }
86e41f4b71Sopenharmony_ci        .listDirection(Axis.Vertical)
87e41f4b71Sopenharmony_ci        .edgeEffect(EdgeEffect.Spring)
88e41f4b71Sopenharmony_ci        .sticky(StickyStyle.Header)
89e41f4b71Sopenharmony_ci        .chainAnimation(false)
90e41f4b71Sopenharmony_ci        .width('100%')
91e41f4b71Sopenharmony_ci      }
92e41f4b71Sopenharmony_ci      .width('100%')
93e41f4b71Sopenharmony_ci      .mode(NavigationMode.Auto)
94e41f4b71Sopenharmony_ci      .title('Settings') // Set the title text.
95e41f4b71Sopenharmony_ci    }
96e41f4b71Sopenharmony_ci    .size({ width: '100%', height: '100%' })
97e41f4b71Sopenharmony_ci    .backgroundColor(0xf4f4f5)
98e41f4b71Sopenharmony_ci  }
99e41f4b71Sopenharmony_ci}
100e41f4b71Sopenharmony_ci```
101e41f4b71Sopenharmony_ci## Creating a Navigation Subpage
102e41f4b71Sopenharmony_ciCreate navigation subpage 1 as follows:
103e41f4b71Sopenharmony_ci
104e41f4b71Sopenharmony_ci1. Use **NavDestination** to create a navigation subpage **CommonPage**.
105e41f4b71Sopenharmony_ci
106e41f4b71Sopenharmony_ci2. Create a navigation stack **NavPathStack** and initialize it in **onReady** to obtain the current page stack to enable transitions between different pages.
107e41f4b71Sopenharmony_ci
108e41f4b71Sopenharmony_ci3. Add an **onClick** method to the components within the subpage and use the **pop** method of the **NavPathStack** to pop the top element of the stack and return to the previous page upon click.
109e41f4b71Sopenharmony_ci```ts
110e41f4b71Sopenharmony_ci//PageOne.ets
111e41f4b71Sopenharmony_ci
112e41f4b71Sopenharmony_ci@Builder
113e41f4b71Sopenharmony_ciexport function MyCommonPageBuilder(name: string, param: string) {
114e41f4b71Sopenharmony_ci  MyCommonPage({ name: name, value: param })
115e41f4b71Sopenharmony_ci}
116e41f4b71Sopenharmony_ci
117e41f4b71Sopenharmony_ci@Component
118e41f4b71Sopenharmony_ciexport struct MyCommonPage {
119e41f4b71Sopenharmony_ci  pathInfos: NavPathStack = new NavPathStack();
120e41f4b71Sopenharmony_ci  name: String = '';
121e41f4b71Sopenharmony_ci  @State value: String = '';
122e41f4b71Sopenharmony_ci
123e41f4b71Sopenharmony_ci  build() {
124e41f4b71Sopenharmony_ci    NavDestination() {
125e41f4b71Sopenharmony_ci      Column() {
126e41f4b71Sopenharmony_ci        Text(`${this.name} settings`)
127e41f4b71Sopenharmony_ci          .width('100%')
128e41f4b71Sopenharmony_ci          .fontSize(20)
129e41f4b71Sopenharmony_ci          .fontColor(0x333333)
130e41f4b71Sopenharmony_ci          .textAlign(TextAlign.Center)
131e41f4b71Sopenharmony_ci          .textShadow({
132e41f4b71Sopenharmony_ci            radius: 2,
133e41f4b71Sopenharmony_ci            offsetX: 4,
134e41f4b71Sopenharmony_ci            offsetY: 4,
135e41f4b71Sopenharmony_ci            color: 0x909399
136e41f4b71Sopenharmony_ci          })
137e41f4b71Sopenharmony_ci          .padding({ top: 30 })
138e41f4b71Sopenharmony_ci        Text(`${JSON.stringify(this.value)}`)
139e41f4b71Sopenharmony_ci          .width('100%')
140e41f4b71Sopenharmony_ci          .fontSize(18)
141e41f4b71Sopenharmony_ci          .fontColor(0x666666)
142e41f4b71Sopenharmony_ci          .textAlign(TextAlign.Center)
143e41f4b71Sopenharmony_ci          .padding({ top: 45 })
144e41f4b71Sopenharmony_ci        Button ('Back')
145e41f4b71Sopenharmony_ci          .width('50%')
146e41f4b71Sopenharmony_ci          .height(40)
147e41f4b71Sopenharmony_ci          .margin({ top: 50 })
148e41f4b71Sopenharmony_ci          .onClick(() => {
149e41f4b71Sopenharmony_ci            // Pop the top element of the stack and return to the previous page.
150e41f4b71Sopenharmony_ci            this.pathInfos.pop();
151e41f4b71Sopenharmony_ci          })
152e41f4b71Sopenharmony_ci      }
153e41f4b71Sopenharmony_ci      .size({ width: '100%', height: '100%' })
154e41f4b71Sopenharmony_ci    }.title(`${this.name}`)
155e41f4b71Sopenharmony_ci    .onReady((ctx: NavDestinationContext) => {
156e41f4b71Sopenharmony_ci      // NavDestinationContext obtains the current page stack.
157e41f4b71Sopenharmony_ci      this.pathInfos = ctx.pathStack;
158e41f4b71Sopenharmony_ci    }) 
159e41f4b71Sopenharmony_ci
160e41f4b71Sopenharmony_ci  }
161e41f4b71Sopenharmony_ci}
162e41f4b71Sopenharmony_ci
163e41f4b71Sopenharmony_ci
164e41f4b71Sopenharmony_ci```
165e41f4b71Sopenharmony_ciCreate navigation subpage 2 as follows:
166e41f4b71Sopenharmony_ci
167e41f4b71Sopenharmony_ci1. Use **NavDestination** to create a navigation subpage **SharePage**.
168e41f4b71Sopenharmony_ci
169e41f4b71Sopenharmony_ci2. Create a navigation stack **NavPathStack** and initialize it in **onReady** to obtain the current page stack to enable transitions between different pages.
170e41f4b71Sopenharmony_ci
171e41f4b71Sopenharmony_ci3. Add an **onClick** method to a component inside the subpage and use the **pushPathByName** method of the **NavPathStack**. This allows the component to transition from the current page to the page corresponding to the input parameter **name** in the routing table upon click.
172e41f4b71Sopenharmony_ci```ts
173e41f4b71Sopenharmony_ci//PageTwo.ets
174e41f4b71Sopenharmony_ci@Builder
175e41f4b71Sopenharmony_ciexport function MySharePageBuilder(name: string, param: string) {
176e41f4b71Sopenharmony_ci  MySharePage({ name: name })
177e41f4b71Sopenharmony_ci}
178e41f4b71Sopenharmony_ci
179e41f4b71Sopenharmony_ci@Component
180e41f4b71Sopenharmony_ciexport struct MySharePage {
181e41f4b71Sopenharmony_ci  pathInfos: NavPathStack = new NavPathStack();
182e41f4b71Sopenharmony_ci  name: String = '';
183e41f4b71Sopenharmony_ci  private listArray: Array<string> = ['Projection', 'Print', 'VPN', 'Private DNS', 'NFC'];
184e41f4b71Sopenharmony_ci
185e41f4b71Sopenharmony_ci  build() {
186e41f4b71Sopenharmony_ci    NavDestination() {
187e41f4b71Sopenharmony_ci      Column() {
188e41f4b71Sopenharmony_ci        List({ space: 12, initialIndex: 0 }) {
189e41f4b71Sopenharmony_ci          ForEach(this.listArray, (item: string) => {
190e41f4b71Sopenharmony_ci            ListItem() {
191e41f4b71Sopenharmony_ci              Row() {
192e41f4b71Sopenharmony_ci                Row() {
193e41f4b71Sopenharmony_ci                  Text(`${item.slice(0, 1)}`)
194e41f4b71Sopenharmony_ci                    .fontColor(Color.White)
195e41f4b71Sopenharmony_ci                    .fontSize(14)
196e41f4b71Sopenharmony_ci                    .fontWeight(FontWeight.Bold)
197e41f4b71Sopenharmony_ci                }
198e41f4b71Sopenharmony_ci                .width(30)
199e41f4b71Sopenharmony_ci                .height(30)
200e41f4b71Sopenharmony_ci                .backgroundColor('#a8a8a8')
201e41f4b71Sopenharmony_ci                .margin({ right: 20 })
202e41f4b71Sopenharmony_ci                .borderRadius(20)
203e41f4b71Sopenharmony_ci                .justifyContent(FlexAlign.Center)
204e41f4b71Sopenharmony_ci
205e41f4b71Sopenharmony_ci                Column() {
206e41f4b71Sopenharmony_ci                  Text(item)
207e41f4b71Sopenharmony_ci                    .fontSize(16)
208e41f4b71Sopenharmony_ci                    .margin({ bottom: 5 })
209e41f4b71Sopenharmony_ci                }
210e41f4b71Sopenharmony_ci                .alignItems(HorizontalAlign.Start)
211e41f4b71Sopenharmony_ci
212e41f4b71Sopenharmony_ci                Blank()
213e41f4b71Sopenharmony_ci
214e41f4b71Sopenharmony_ci                Row()
215e41f4b71Sopenharmony_ci                  .width(12)
216e41f4b71Sopenharmony_ci                  .height(12)
217e41f4b71Sopenharmony_ci                  .margin({ right: 15 })
218e41f4b71Sopenharmony_ci                  .border({
219e41f4b71Sopenharmony_ci                    width: { top: 2, right: 2 },
220e41f4b71Sopenharmony_ci                    color: 0xcccccc
221e41f4b71Sopenharmony_ci                  })
222e41f4b71Sopenharmony_ci                  .rotate({ angle: 45 })
223e41f4b71Sopenharmony_ci              }
224e41f4b71Sopenharmony_ci              .borderRadius(15)
225e41f4b71Sopenharmony_ci              .shadow({ radius: 100, color: '#ededed' })
226e41f4b71Sopenharmony_ci              .width('90%')
227e41f4b71Sopenharmony_ci              .alignItems(VerticalAlign.Center)
228e41f4b71Sopenharmony_ci              .padding({ left: 15, top: 15, bottom: 15 })
229e41f4b71Sopenharmony_ci              .backgroundColor(Color.White)
230e41f4b71Sopenharmony_ci            }
231e41f4b71Sopenharmony_ci            .width('100%')
232e41f4b71Sopenharmony_ci            .onClick(() => {
233e41f4b71Sopenharmony_ci              this.pathInfos.pushPathByName(`${item}`, 'Parameters')
234e41f4b71Sopenharmony_ci            })
235e41f4b71Sopenharmony_ci          }, (item: string): string => item)
236e41f4b71Sopenharmony_ci        }
237e41f4b71Sopenharmony_ci        .listDirection(Axis.Vertical)
238e41f4b71Sopenharmony_ci        .edgeEffect(EdgeEffect.Spring)
239e41f4b71Sopenharmony_ci        .sticky(StickyStyle.Header)
240e41f4b71Sopenharmony_ci        .width('100%')
241e41f4b71Sopenharmony_ci      }
242e41f4b71Sopenharmony_ci      .size({ width: '100%', height: '100%' })
243e41f4b71Sopenharmony_ci    }.title(`${this.name}`)
244e41f4b71Sopenharmony_ci    .onReady((ctx: NavDestinationContext) => {
245e41f4b71Sopenharmony_ci      // NavDestinationContext obtains the current page stack.
246e41f4b71Sopenharmony_ci      this.pathInfos = ctx.pathStack;
247e41f4b71Sopenharmony_ci    }) 
248e41f4b71Sopenharmony_ci  }
249e41f4b71Sopenharmony_ci}
250e41f4b71Sopenharmony_ci```
251e41f4b71Sopenharmony_ci## Creating Route Navigation
252e41f4b71Sopenharmony_ciTo create route navigation:
253e41f4b71Sopenharmony_ci
254e41f4b71Sopenharmony_ci1. In the project configuration file **module.json5**, add the configuration **{"routerMap": "$profile:route_map"}**.
255e41f4b71Sopenharmony_ci
256e41f4b71Sopenharmony_ci2. In the **route_map.json** file, define the global routing table. The navigation stack **NavPathStack** can push the corresponding page information onto the stack based on the name in the routing table.
257e41f4b71Sopenharmony_ci```ts
258e41f4b71Sopenharmony_ci{
259e41f4b71Sopenharmony_ci  "routerMap" : [
260e41f4b71Sopenharmony_ci    {
261e41f4b71Sopenharmony_ci      "name" : "WLAN",
262e41f4b71Sopenharmony_ci      "pageSourceFile"  : "src/main/ets/pages/PageOne.ets",
263e41f4b71Sopenharmony_ci      "buildFunction" : "MyCommonPageBuilder"
264e41f4b71Sopenharmony_ci    },
265e41f4b71Sopenharmony_ci    {
266e41f4b71Sopenharmony_ci      "name" : "Bluetooth",
267e41f4b71Sopenharmony_ci      "pageSourceFile"  : "src/main/ets/pages/PageOne.ets",
268e41f4b71Sopenharmony_ci      "buildFunction" : "MyCommonPageBuilder"
269e41f4b71Sopenharmony_ci    },
270e41f4b71Sopenharmony_ci    {
271e41f4b71Sopenharmony_ci      "name" : "Personal Hotpot",
272e41f4b71Sopenharmony_ci      "pageSourceFile"  : "src/main/ets/pages/PageOne.ets",
273e41f4b71Sopenharmony_ci      "buildFunction" : "MyCommonPageBuilder"
274e41f4b71Sopenharmony_ci    },
275e41f4b71Sopenharmony_ci    {
276e41f4b71Sopenharmony_ci      "name" : "Connect & Share",
277e41f4b71Sopenharmony_ci      "pageSourceFile"  : "src/main/ets/pages/PageTwo.ets",
278e41f4b71Sopenharmony_ci      "buildFunction" : "MySharePageBuilder"
279e41f4b71Sopenharmony_ci    },
280e41f4b71Sopenharmony_ci    {
281e41f4b71Sopenharmony_ci      "name" : "Projection",
282e41f4b71Sopenharmony_ci      "pageSourceFile"  : "src/main/ets/pages/PageOne.ets",
283e41f4b71Sopenharmony_ci      "buildFunction" : "MyCommonPageBuilder"
284e41f4b71Sopenharmony_ci    },
285e41f4b71Sopenharmony_ci    {
286e41f4b71Sopenharmony_ci      "name" : "Print",
287e41f4b71Sopenharmony_ci      "pageSourceFile"  : "src/main/ets/pages/PageOne.ets",
288e41f4b71Sopenharmony_ci      "buildFunction" : "MyCommonPageBuilder"
289e41f4b71Sopenharmony_ci    },
290e41f4b71Sopenharmony_ci    {
291e41f4b71Sopenharmony_ci      "name" : "VPN",
292e41f4b71Sopenharmony_ci      "pageSourceFile"  : "src/main/ets/pages/PageOne.ets",
293e41f4b71Sopenharmony_ci      "buildFunction" : "MyCommonPageBuilder"
294e41f4b71Sopenharmony_ci    },
295e41f4b71Sopenharmony_ci    {
296e41f4b71Sopenharmony_ci      "name" : "Private DNS",
297e41f4b71Sopenharmony_ci      "pageSourceFile"  : "src/main/ets/pages/PageOne.ets",
298e41f4b71Sopenharmony_ci      "buildFunction" : "MyCommonPageBuilder"
299e41f4b71Sopenharmony_ci    },
300e41f4b71Sopenharmony_ci    {
301e41f4b71Sopenharmony_ci      "name" : "NFC",
302e41f4b71Sopenharmony_ci      "pageSourceFile"  : "src/main/ets/pages/PageOne.ets",
303e41f4b71Sopenharmony_ci      "buildFunction" : "MyCommonPageBuilder"
304e41f4b71Sopenharmony_ci    }
305e41f4b71Sopenharmony_ci  ]
306e41f4b71Sopenharmony_ci}
307e41f4b71Sopenharmony_ci```
308e41f4b71Sopenharmony_ci
309e41f4b71Sopenharmony_ci![en-us_image_0000001588458252](figures/arkts-navigation-transition_1.gif)
310