Skip to content

Commit f97fa42

Browse files
docs(slides): update React and Vue migration guides to be compatible with Swiper 9 (#2819)
1 parent 4edfc27 commit f97fa42

File tree

4 files changed

+50
-62
lines changed

4 files changed

+50
-62
lines changed

docs/react/slides.md

+16-23
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Slides
2+
title: Migrating From IonSlides to Swiper.js
33
---
44

55
<head>
@@ -16,12 +16,13 @@ title: Slides
1616

1717
:::
1818

19-
:::note
20-
This migration guide is compatible with Swiper 8. An updated guide for Swiper 9 is coming soon!
21-
:::
19+
We recommend <a href="http://swiperjs.com/" target="_blank" rel="noopener noreferrer">Swiper.js</a> if you need a modern touch slider component. This guide will go over how to get Swiper for React set up in your Ionic Framework application. It will also go over any migration information you may need to move from `IonSlides` to the official Swiper React integration.
2220

21+
:::note
22+
Swiper's React component is set to be removed in a future release of Swiper, with <a href="https://swiperjs.com/element" target="_blank" rel="noopener noreferrer">Swiper Element</a> as the replacement. However, this guide shows how to migrate to the React component because it provides the most stable experience at the time of writing. Notably, React does not have strong support for Web Components yet.
2323

24-
We recommend <a href="http://swiperjs.com/" target="_blank" rel="noopener noreferrer">Swiper.js</a> if you need a modern touch slider component. This guide will go over how to get Swiper for React set up in your Ionic Framework application. It will also go over any migration information you may need to move from `IonSlides` to the official Swiper React integration.
24+
Using Swiper's React component is **not** required to use Swiper.js with Ionic Framework.
25+
:::
2526

2627
## Getting Started
2728

@@ -34,7 +35,7 @@ npm install @ionic/react@latest @ionic/react-router@latest
3435
Once that is done, install the Swiper dependency in your project:
3536

3637
```shell
37-
npm install swiper@8
38+
npm install swiper@latest
3839
```
3940

4041
:::note
@@ -43,7 +44,7 @@ Create React App does not support pure ESM packages yet. Developers can still us
4344

4445
## Swiping with Style
4546

46-
Next, we need to import the base Swiper styles. We are also going to import the styles that Ionic provides which will let us customize the Swiper styles using the same CSS Variables that we used with `ion-slides`.
47+
Next, we need to import the base Swiper styles. We are also going to import the styles that Ionic provides which will let us customize the Swiper styles using the same CSS Variables that we used with `IonSlides`.
4748

4849
We recommend importing the styles in the component in which Swiper is being used. This ensures that the styles are only loaded when needed:
4950

@@ -64,13 +65,11 @@ export default Home;
6465
```
6566

6667
:::note
67-
Importing `@ionic/react/css/ionic-swiper.css'` is **not** required to use Swiper.js with Ionic. This files is used for backward-compatibility with the `ion-slides` component and can be safely omitted if you prefer not to use the CSS Variables provided in the stylesheet.
68+
Importing `@ionic/react/css/ionic-swiper.css` is **not** required to use Swiper.js with Ionic. This files is used for backward-compatibility with the `IonSlides` component and can be safely omitted if you prefer not to use the CSS Variables provided in the stylesheet.
6869
:::
6970

7071
:::note
71-
7272
Not using Create React App? You can import the Swiper CSS from `swiper/css` instead.
73-
7473
:::
7574

7675
### Updating Selectors
@@ -153,16 +152,14 @@ export default Home;
153152
```
154153

155154
:::note
156-
157155
Not using Create React App? You can import the Swiper components from `swiper/react` instead.
158-
159156
:::
160157

161158
## Using Modules
162159

163160
By default, Swiper for React does not import any additional modules. To use modules such as Navigation or Pagination, you need to import them first.
164161

165-
`ion-slides` automatically included the Pagination, Scrollbar, Autoplay, Keyboard, and Zoom modules. This part of the guide will show you how to install these modules.
162+
`IonSlides` automatically included the Pagination, Scrollbar, Autoplay, Keyboard, and Zoom modules. This part of the guide will show you how to install these modules.
166163

167164
To begin, we need to import the modules and their corresponding CSS files from the `swiper` package:
168165

@@ -197,9 +194,7 @@ export default Home;
197194
```
198195

199196
:::note
200-
201197
Not using Create React App? You can import these modules from `swiper/css/[MODULE NAME]` instead (i.e. `swiper/css/autoplay`).
202-
203198
:::
204199

205200
From here, we need to provide these modules to Swiper by using the `modules` property on the `Swiper` component:
@@ -279,7 +274,7 @@ See <a href="https://swiperjs.com/react#usage" target="_blank" rel="noopener nor
279274

280275
## The IonicSlides Module
281276

282-
With `ion-slides`, Ionic automatically customized dozens of Swiper properties. This resulted in an experience that felt smooth when swiping on mobile devices. We recommend using the `IonicSlides` module to ensure that these properties are also set when using Swiper directly. However, using this module is **not** required to use Swiper.js in Ionic.
277+
With `IonSlides`, Ionic automatically customized dozens of Swiper properties. This resulted in an experience that felt smooth when swiping on mobile devices. We recommend using the `IonicSlides` module to ensure that these properties are also set when using Swiper directly. However, using this module is **not** required to use Swiper.js in Ionic.
283278

284279
We can install the `IonicSlides` module by importing it from `@ionic/react` and passing it in as the last item in the `modules` array:
285280

@@ -428,7 +423,7 @@ Below is a full list of event name changes when going from `IonSlides` to Swiper
428423
| onIonSlidesDidLoad | onInit |
429424

430425
:::note
431-
All events available in Swiper React can be found at <a href="https://swiperjs.com/react#swiper-events" target="_blank" rel="noopener noreferrer">https://swiperjs.com/react#swiper-events</a>.
426+
All events available in Swiper can be found at <a href="https://swiperjs.com/swiper-api#events" target="_blank" rel="noopener noreferrer">https://swiperjs.com/swiper-api#events</a>.
432427
:::
433428

434429
## Methods
@@ -460,7 +455,7 @@ From here, if you wanted to access a property on the Swiper instance you would a
460455

461456
Below is a full list of method changes when going from `IonSlides` to Swiper React:
462457

463-
| ion-slides Method | Notes |
458+
| IonSlides Method | Notes |
464459
| ------------------ | ------------------------------------------------------------------------------------ |
465460
| getActiveIndex() | Use the `activeIndex` property instead. |
466461
| getPreviousIndex() | Use the `previousIndex` property instead. |
@@ -491,7 +486,7 @@ const Home: React.FC = () => {
491486
return (
492487
<IonPage>
493488
<IonContent>
494-
<Swiper modules={[EffectFact, IonicSlides]}>
489+
<Swiper modules={[EffectFade, IonicSlides]}>
495490
<SwiperSlide>Slide 1</SwiperSlide>
496491
<SwiperSlide>Slide 2</SwiperSlide>
497492
<SwiperSlide>Slide 3</SwiperSlide>
@@ -519,7 +514,7 @@ const Home: React.FC = () => {
519514
return (
520515
<IonPage>
521516
<IonContent>
522-
<Swiper modules={[EffectFact, IonicSlides]}>
517+
<Swiper modules={[EffectFade, IonicSlides]}>
523518
<SwiperSlide>Slide 1</SwiperSlide>
524519
<SwiperSlide>Slide 2</SwiperSlide>
525520
<SwiperSlide>Slide 3</SwiperSlide>
@@ -532,9 +527,7 @@ export default Home;
532527
```
533528

534529
:::note
535-
536530
Not using Create React App? You can import these effects from `swiper/css/[EFFECT NAME]` instead (i.e. `swiper/css/effect-fade`).
537-
538531
:::
539532

540533
After that, we can activate it by setting the `effect` property on `swiper` to `"fade"`:
@@ -553,7 +546,7 @@ const Home: React.FC = () => {
553546
return (
554547
<IonPage>
555548
<IonContent>
556-
<Swiper modules={[EffectFact, IonicSlides]} swiper="fade">
549+
<Swiper modules={[EffectFade, IonicSlides]} effect="fade">
557550
<SwiperSlide>Slide 1</SwiperSlide>
558551
<SwiperSlide>Slide 2</SwiperSlide>
559552
<SwiperSlide>Slide 3</SwiperSlide>

docs/vue/slides.md

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Slides
2+
title: Migrating From ion-slides to Swiper.js
33
---
44

55
<head>
@@ -11,17 +11,16 @@ title: Slides
1111
</head>
1212

1313
:::caution Looking for `ion-slides`?
14-
1514
`ion-slides` was deprecated in v6.0.0 and removed in v7.0.0. We recommend using the Swiper.js library directly. The migration process is detailed below.
16-
1715
:::
1816

19-
:::note
20-
This migration guide is compatible with Swiper 8. An updated guide for Swiper 9 is coming soon!
21-
:::
17+
We recommend <a href="http://swiperjs.com/" target="_blank" rel="noopener noreferrer">Swiper.js</a> if you need a modern touch slider component. This guide will go over how to get Swiper for Vue set up in your Ionic Framework application. It will also go over any migration information you may need to move from `ion-slides` to the official Swiper Vue integration.
2218

19+
:::note
20+
Swiper's Vue component is set to be removed in a future release of Swiper, with <a href="https://swiperjs.com/element" target="_blank" rel="noopener noreferrer">Swiper Element</a> as the replacement. However, this guide shows how to migrate to the Vue component because it provides the most stable experience at the time of writing.
2321

24-
We recommend <a href="http://swiperjs.com/" target="_blank" rel="noopener noreferrer">Swiper.js</a> if you need a modern touch slider component. This guide will go over how to get Swiper for Vue set up in your Ionic Framework application. It will also go over any migration information you may need to move from `ion-slides` to the official Swiper Vue integration.
22+
Using Swiper's Vue component is **not** required to use Swiper.js with Ionic Framework.
23+
:::
2524

2625
## Getting Started
2726

@@ -40,7 +39,7 @@ vue upgrade --next
4039
Once that is done, install the Swiper dependency in your project:
4140

4241
```shell
43-
npm install swiper@8
42+
npm install swiper@latest
4443
```
4544

4645
## Swiping with Style
@@ -63,7 +62,7 @@ We recommend importing the styles in the component in which Swiper is being used
6362
```
6463

6564
:::note
66-
Importing `@ionic/vue/css/ionic-swiper.css'` is **not** required to use Swiper.js with Ionic. This files is used for backward-compatibility with the `ion-slides` component and can be safely omitted if you prefer not to use the CSS Variables provided in the stylesheet.
65+
Importing `@ionic/vue/css/ionic-swiper.css` is **not** required to use Swiper.js with Ionic. This files is used for backward-compatibility with the `ion-slides` component and can be safely omitted if you prefer not to use the CSS Variables provided in the stylesheet.
6766
:::
6867

6968
### Updating Selectors

versioned_docs/version-v6/react/slides.md

+17-23
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Slides
2+
title: Migrating From IonSlides to Swiper.js
33
---
44

55
<head>
@@ -10,14 +10,16 @@ title: Slides
1010
/>
1111
</head>
1212

13-
:::note
14-
This migration guide is compatible with Swiper 8. An updated guide for Swiper 9 is coming soon!
15-
:::
16-
1713
We recommend <a href="http://swiperjs.com/" target="_blank" rel="noopener noreferrer">Swiper.js</a> if you need a modern touch slider component. It powers our `IonSlides` component, but we now recommend that developers use Swiper for React directly.
1814

1915
This guide will go over how to get Swiper for React set up in your Ionic Framework application. It will also go over any migration information you may need to move from `IonSlides` to the official Swiper React integration.
2016

17+
:::note
18+
Swiper's React component is set to be removed in a future release of Swiper, with <a href="https://swiperjs.com/element" target="_blank" rel="noopener noreferrer">Swiper Element</a> as the replacement. However, this guide shows how to migrate to the React component because it provides the most stable experience at the time of writing. Notably, React does not have strong support for Web Components yet.
19+
20+
Using Swiper's React component is **not** required to use Swiper.js with Ionic Framework.
21+
:::
22+
2123
## Getting Started
2224

2325
First, update to the latest version of Ionic:
@@ -29,7 +31,7 @@ npm install @ionic/react@latest @ionic/react-router@latest
2931
Once that is done, install the Swiper dependency in your project:
3032

3133
```shell
32-
npm install swiper@8
34+
npm install swiper@latest
3335
```
3436

3537
:::note
@@ -38,7 +40,7 @@ Create React App does not support pure ESM packages yet. Developers can still us
3840

3941
## Swiping with Style
4042

41-
Next, we need to import the base Swiper styles. We are also going to import the styles that Ionic provides which will let us customize the Swiper styles using the same CSS Variables that we used with `ion-slides`.
43+
Next, we need to import the base Swiper styles. We are also going to import the styles that Ionic provides which will let us customize the Swiper styles using the same CSS Variables that we used with `IonSlides`.
4244

4345
We recommend importing the styles in the component in which Swiper is being used. This ensures that the styles are only loaded when needed:
4446

@@ -59,13 +61,11 @@ export default Home;
5961
```
6062

6163
:::note
62-
Importing `@ionic/react/css/ionic-swiper.css'` is **not** required to use Swiper.js with Ionic. This files is used for backward-compatibility with the `ion-slides` component and can be safely omitted if you prefer not to use the CSS Variables provided in the stylesheet.
64+
Importing `@ionic/react/css/ionic-swiper.css` is **not** required to use Swiper.js with Ionic. This files is used for backward-compatibility with the `IonSlides` component and can be safely omitted if you prefer not to use the CSS Variables provided in the stylesheet.
6365
:::
6466

6567
:::note
66-
6768
Not using Create React App? You can import the Swiper CSS from `swiper/css` instead.
68-
6969
:::
7070

7171
### Updating Selectors
@@ -148,16 +148,14 @@ export default Home;
148148
```
149149

150150
:::note
151-
152151
Not using Create React App? You can import the Swiper components from `swiper/react` instead.
153-
154152
:::
155153

156154
## Using Modules
157155

158156
By default, Swiper for React does not import any additional modules. To use modules such as Navigation or Pagination, you need to import them first.
159157

160-
`ion-slides` automatically included the Pagination, Scrollbar, Autoplay, Keyboard, and Zoom modules. This part of the guide will show you how to install these modules.
158+
`IonSlides` automatically included the Pagination, Scrollbar, Autoplay, Keyboard, and Zoom modules. This part of the guide will show you how to install these modules.
161159

162160
To begin, we need to import the modules and their corresponding CSS files from the `swiper` package:
163161

@@ -192,9 +190,7 @@ export default Home;
192190
```
193191

194192
:::note
195-
196193
Not using Create React App? You can import these modules from `swiper/css/[MODULE NAME]` instead (i.e. `swiper/css/autoplay`).
197-
198194
:::
199195

200196
From here, we need to provide these modules to Swiper by using the `modules` property on the `Swiper` component:
@@ -274,7 +270,7 @@ See <a href="https://swiperjs.com/react#usage" target="_blank" rel="noopener nor
274270

275271
## The IonicSlides Module
276272

277-
With `ion-slides`, Ionic automatically customized dozens of Swiper properties. This resulted in an experience that felt smooth when swiping on mobile devices. We recommend using the `IonicSlides` module to ensure that these properties are also set when using Swiper directly. However, using this module is **not** required to use Swiper.js in Ionic.
273+
With `IonSlides`, Ionic automatically customized dozens of Swiper properties. This resulted in an experience that felt smooth when swiping on mobile devices. We recommend using the `IonicSlides` module to ensure that these properties are also set when using Swiper directly. However, using this module is **not** required to use Swiper.js in Ionic.
278274

279275
We can install the `IonicSlides` module by importing it from `@ionic/react` and passing it in as the last item in the `modules` array:
280276

@@ -423,7 +419,7 @@ Below is a full list of event name changes when going from `IonSlides` to Swiper
423419
| onIonSlidesDidLoad | onInit |
424420

425421
:::note
426-
All events available in Swiper React can be found at <a href="https://swiperjs.com/react#swiper-events" target="_blank" rel="noopener noreferrer">https://swiperjs.com/react#swiper-events</a>.
422+
All events available in Swiper can be found at <a href="https://swiperjs.com/swiper-api#events" target="_blank" rel="noopener noreferrer">https://swiperjs.com/swiper-api#events</a>.
427423
:::
428424

429425
## Methods
@@ -455,7 +451,7 @@ From here, if you wanted to access a property on the Swiper instance you would a
455451

456452
Below is a full list of method changes when going from `IonSlides` to Swiper React:
457453

458-
| ion-slides Method | Notes |
454+
| IonSlides Method | Notes |
459455
| ------------------ | ------------------------------------------------------------------------------------ |
460456
| getActiveIndex() | Use the `activeIndex` property instead. |
461457
| getPreviousIndex() | Use the `previousIndex` property instead. |
@@ -486,7 +482,7 @@ const Home: React.FC = () => {
486482
return (
487483
<IonPage>
488484
<IonContent>
489-
<Swiper modules={[EffectFact, IonicSlides]}>
485+
<Swiper modules={[EffectFade, IonicSlides]}>
490486
<SwiperSlide>Slide 1</SwiperSlide>
491487
<SwiperSlide>Slide 2</SwiperSlide>
492488
<SwiperSlide>Slide 3</SwiperSlide>
@@ -514,7 +510,7 @@ const Home: React.FC = () => {
514510
return (
515511
<IonPage>
516512
<IonContent>
517-
<Swiper modules={[EffectFact, IonicSlides]}>
513+
<Swiper modules={[EffectFade, IonicSlides]}>
518514
<SwiperSlide>Slide 1</SwiperSlide>
519515
<SwiperSlide>Slide 2</SwiperSlide>
520516
<SwiperSlide>Slide 3</SwiperSlide>
@@ -527,9 +523,7 @@ export default Home;
527523
```
528524

529525
:::note
530-
531526
Not using Create React App? You can import these effects from `swiper/css/[EFFECT NAME]` instead (i.e. `swiper/css/effect-fade`).
532-
533527
:::
534528

535529
After that, we can activate it by setting the `effect` property on `swiper` to `"fade"`:
@@ -548,7 +542,7 @@ const Home: React.FC = () => {
548542
return (
549543
<IonPage>
550544
<IonContent>
551-
<Swiper modules={[EffectFact, IonicSlides]} swiper="fade">
545+
<Swiper modules={[EffectFade, IonicSlides]} effect="fade">
552546
<SwiperSlide>Slide 1</SwiperSlide>
553547
<SwiperSlide>Slide 2</SwiperSlide>
554548
<SwiperSlide>Slide 3</SwiperSlide>

versioned_docs/version-v6/vue/slides.md

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Slides
2+
title: Migrating From ion-slides to Swiper.js
33
---
44

55
<head>
@@ -10,14 +10,16 @@ title: Slides
1010
/>
1111
</head>
1212

13-
:::note
14-
This migration guide is compatible with Swiper 8. An updated guide for Swiper 9 is coming soon!
15-
:::
16-
1713
We recommend <a href="http://swiperjs.com/" target="_blank" rel="noopener noreferrer">Swiper.js</a> if you need a modern touch slider component. It powers our `ion-slides` component, but we now recommend that developers use Swiper for Vue directly.
1814

1915
This guide will go over how to get Swiper for Vue set up in your Ionic Framework application. It will also go over any migration information you may need to move from `ion-slides` to the official Swiper Vue integration.
2016

17+
:::note
18+
Swiper's Vue component is set to be removed in a future release of Swiper, with <a href="https://swiperjs.com/element" target="_blank" rel="noopener noreferrer">Swiper Element</a> as the replacement. However, this guide shows how to migrate to the Vue component because it provides the most stable experience at the time of writing.
19+
20+
Using Swiper's Vue component is **not** required to use Swiper.js with Ionic Framework.
21+
:::
22+
2123
## Getting Started
2224

2325
First, update to the latest version of Ionic:
@@ -35,7 +37,7 @@ vue upgrade --next
3537
Once that is done, install the Swiper dependency in your project:
3638

3739
```shell
38-
npm install swiper@8
40+
npm install swiper@latest
3941
```
4042

4143
## Swiping with Style
@@ -58,7 +60,7 @@ We recommend importing the styles in the component in which Swiper is being used
5860
```
5961

6062
:::note
61-
Importing `@ionic/vue/css/ionic-swiper.css'` is **not** required to use Swiper.js with Ionic. This files is used for backward-compatibility with the `ion-slides` component and can be safely omitted if you prefer not to use the CSS Variables provided in the stylesheet.
63+
Importing `@ionic/vue/css/ionic-swiper.css` is **not** required to use Swiper.js with Ionic. This files is used for backward-compatibility with the `ion-slides` component and can be safely omitted if you prefer not to use the CSS Variables provided in the stylesheet.
6264
:::
6365

6466
### Updating Selectors

0 commit comments

Comments
 (0)