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
@@ -163,9 +164,9 @@ For detailed information about Ionic layout components, see the [Header](/docs/a
163
164
164
165
## Add an Ionic Component
165
166
166
-
You can enhance your Home page with more Ionic UI components. For example, import and add a [Button](/docs/api/button) at the end of the `IonContent` in `pages/Home.tsx`:
167
+
You can enhance your Home page with more Ionic UI components. For example, import and add a [Button](/docs/api/button) at the end of the `IonContent` in `src/pages/Home.tsx`:
This creates a page with a [Back Button](/docs/api/back-button) in the [Toolbar](/docs/api/toolbar). The back button will automatically handle navigation back to the previous page, or to `/` if there is no history.
225
226
226
-
:::warning Important
227
+
:::warning
227
228
When creating your own pages, always use `IonPage` as the root component. This is essential for proper transitions between pages, base CSS styling that Ionic components depend on, and consistent layout behavior across your app.
228
229
:::
229
230
230
231
## Navigate to the New Page
231
232
232
-
To navigate to the new page, create a route for it by first importing it at the top of `App.tsx` after the `Home` import:
233
+
To navigate to the new page, create a route for it by first importing it at the top of `src/App.tsx` after the `Home` import:
233
234
234
-
```tsx
235
+
```tsx title="src/App.tsx"
235
236
importNewfrom'./pages/New';
236
237
```
237
238
238
239
Then, add its route in `IonRouterOutlet`:
239
240
240
-
```tsx
241
+
```tsx title="src/App.tsx"
241
242
<IonRouterOutlet>
242
243
<Routeexactpath="/home">
243
244
<Home />
@@ -251,9 +252,9 @@ Then, add its route in `IonRouterOutlet`:
251
252
</IonRouterOutlet>
252
253
```
253
254
254
-
Once that is done, update the button in `pages/Home.tsx`:
255
+
Once that is done, update the button in `src/pages/Home.tsx`:
255
256
256
-
```tsx
257
+
```tsx title="src/pages/Home.tsx"
257
258
<IonButtonrouterLink="/new">Navigate</IonButton>
258
259
```
259
260
@@ -265,16 +266,16 @@ Navigating can also be performed programmatically using React Router's `history`
265
266
266
267
Ionic React comes with [Ionicons](https://ionic.io/ionicons/) pre-installed. You can use any icon by setting the `icon` property of the `IonIcon` component.
267
268
268
-
Update the imports in `pages/New.tsx` to import `IonIcon` and the `heart` and `logoIonic` icons:
269
+
Update the imports in `src/pages/New.tsx` to import `IonIcon` and the `heart` and `logoIonic` icons:
@@ -163,9 +164,9 @@ For detailed information about Ionic layout components, see the [Header](/docs/a
163
164
164
165
## Add an Ionic Component
165
166
166
-
You can enhance your Home page with more Ionic UI components. For example, import and add a [Button](/docs/api/button) at the end of the `IonContent` in `pages/Home.tsx`:
167
+
You can enhance your Home page with more Ionic UI components. For example, import and add a [Button](/docs/api/button) at the end of the `IonContent` in `src/pages/Home.tsx`:
This creates a page with a [Back Button](/docs/api/back-button) in the [Toolbar](/docs/api/toolbar). The back button will automatically handle navigation back to the previous page, or to `/` if there is no history.
225
226
226
-
:::warning Important
227
+
:::warning
227
228
When creating your own pages, always use `IonPage` as the root component. This is essential for proper transitions between pages, base CSS styling that Ionic components depend on, and consistent layout behavior across your app.
228
229
:::
229
230
230
231
## Navigate to the New Page
231
232
232
-
To navigate to the new page, create a route for it by first importing it at the top of `App.tsx` after the `Home` import:
233
+
To navigate to the new page, create a route for it by first importing it at the top of `src/App.tsx` after the `Home` import:
233
234
234
-
```tsx
235
+
```tsx title="src/App.tsx"
235
236
importNewfrom'./pages/New';
236
237
```
237
238
238
239
Then, add its route in `IonRouterOutlet`:
239
240
240
-
```tsx
241
+
```tsx title="src/App.tsx"
241
242
<IonRouterOutlet>
242
243
<Routeexactpath="/home">
243
244
<Home />
@@ -251,9 +252,9 @@ Then, add its route in `IonRouterOutlet`:
251
252
</IonRouterOutlet>
252
253
```
253
254
254
-
Once that is done, update the button in `pages/Home.tsx`:
255
+
Once that is done, update the button in `src/pages/Home.tsx`:
255
256
256
-
```tsx
257
+
```tsx title="src/pages/Home.tsx"
257
258
<IonButtonrouterLink="/new">Navigate</IonButton>
258
259
```
259
260
@@ -265,16 +266,16 @@ Navigating can also be performed programmatically using React Router's `history`
265
266
266
267
Ionic React comes with [Ionicons](https://ionic.io/ionicons/) pre-installed. You can use any icon by setting the `icon` property of the `IonIcon` component.
267
268
268
-
Update the imports in `pages/New.tsx` to import `IonIcon` and the `heart` and `logoIonic` icons:
269
+
Update the imports in `src/pages/New.tsx` to import `IonIcon` and the `heart` and `logoIonic` icons:
0 commit comments