1e41f4b71Sopenharmony_ci# swiper
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci
4e41f4b71Sopenharmony_ciThe **\<Swiper>** component provides a container that allows users to switch among child components using swipe gestures.
5e41f4b71Sopenharmony_ci
6e41f4b71Sopenharmony_ci
7e41f4b71Sopenharmony_ci> **NOTE**
8e41f4b71Sopenharmony_ci>
9e41f4b71Sopenharmony_ci> The APIs of this module are supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci## Attributes
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_ciIn addition to the [universal attributes](js-service-widget-common-attributes.md), the following attributes are supported.
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ci| Name       | Type     | Default Value  | Mandatory  | Description                                      |
18e41f4b71Sopenharmony_ci| --------- | ------- | ----- | ---- | ---------------------------------------- |
19e41f4b71Sopenharmony_ci| index     | number  | 0     | No   | Index of the child component currently displayed in the container.                       |
20e41f4b71Sopenharmony_ci| indicator | boolean | true  | No   | Whether to enable the indicator. The default value is **true**.                      |
21e41f4b71Sopenharmony_ci| digital   | boolean | false | No   | Whether to enable the digital indicator. The default value is **false**.<br>The digital indicator takes effect only when **indicator** is set to **true**.|
22e41f4b71Sopenharmony_ci| loop      | boolean | true  | No   | Whether to enable looping.                               |
23e41f4b71Sopenharmony_ci| duration  | number  | -     | No   | Duration of the autoplay for child component switching.                             |
24e41f4b71Sopenharmony_ci| vertical  | boolean | false | No   | Whether the swipe gesture is performed vertically. A vertical swipe uses the vertical indicator.                  |
25e41f4b71Sopenharmony_ci
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci## Styles
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ciIn addition to the [universal styles](js-service-widget-common-styles.md), the following styles are supported.
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ci| Name                                | Type                                      | Default Value | Mandatory  | Description                  |
32e41f4b71Sopenharmony_ci| ---------------------------------- | ---------------------------------------- | ---- | ---- | -------------------- |
33e41f4b71Sopenharmony_ci| indicator-color                    | &lt;color&gt;                            | -    | No   | Fill color of the indicator.        |
34e41f4b71Sopenharmony_ci| indicator-selected-color           | &lt;color&gt;                            | -    | No   | Color of the currently selected indicator.        |
35e41f4b71Sopenharmony_ci| indicator-size                     | &lt;length&gt;                           | 4px  | No   | Diameter of the indicator.        |
36e41f4b71Sopenharmony_ci| indicator-top\|left\|right\|bottom | &lt;length&gt; \| &lt;percentage&gt; | -    | No   | Relative position of the indicator in the swiper.|
37e41f4b71Sopenharmony_ci
38e41f4b71Sopenharmony_ci
39e41f4b71Sopenharmony_ci## Events
40e41f4b71Sopenharmony_ci
41e41f4b71Sopenharmony_ciThe [universal events](js-service-widget-common-events.md) are supported.
42e41f4b71Sopenharmony_ci
43e41f4b71Sopenharmony_ci
44e41f4b71Sopenharmony_ci## Example
45e41f4b71Sopenharmony_ci
46e41f4b71Sopenharmony_ci
47e41f4b71Sopenharmony_ci```html
48e41f4b71Sopenharmony_ci<!-- xxx.hml -->
49e41f4b71Sopenharmony_ci<swiper class="container" index="{{index}}">
50e41f4b71Sopenharmony_ci  <div class="swiper-item primary-item">
51e41f4b71Sopenharmony_ci    <text>1</text>
52e41f4b71Sopenharmony_ci  </div>
53e41f4b71Sopenharmony_ci  <div class="swiper-item warning-item">
54e41f4b71Sopenharmony_ci    <text>2</text>
55e41f4b71Sopenharmony_ci  </div>
56e41f4b71Sopenharmony_ci  <div class="swiper-item success-item">
57e41f4b71Sopenharmony_ci    <text>3</text>
58e41f4b71Sopenharmony_ci  </div>
59e41f4b71Sopenharmony_ci</swiper>
60e41f4b71Sopenharmony_ci```
61e41f4b71Sopenharmony_ci
62e41f4b71Sopenharmony_ci
63e41f4b71Sopenharmony_ci```css
64e41f4b71Sopenharmony_ci/* xxx.css */
65e41f4b71Sopenharmony_ci.container {
66e41f4b71Sopenharmony_ci  left: 0px;
67e41f4b71Sopenharmony_ci  top: 0px;
68e41f4b71Sopenharmony_ci  width: 454px;
69e41f4b71Sopenharmony_ci  height: 454px;
70e41f4b71Sopenharmony_ci}
71e41f4b71Sopenharmony_ci.swiper-item {
72e41f4b71Sopenharmony_ci  width: 454px;
73e41f4b71Sopenharmony_ci  height: 454px;
74e41f4b71Sopenharmony_ci  justify-content: center;
75e41f4b71Sopenharmony_ci  align-items: center;
76e41f4b71Sopenharmony_ci}
77e41f4b71Sopenharmony_ci.primary-item {
78e41f4b71Sopenharmony_ci  background-color: #007dff;
79e41f4b71Sopenharmony_ci}
80e41f4b71Sopenharmony_ci.warning-item {
81e41f4b71Sopenharmony_ci  background-color: #ff7500;
82e41f4b71Sopenharmony_ci}
83e41f4b71Sopenharmony_ci.success-item {
84e41f4b71Sopenharmony_ci  background-color: #41ba41;
85e41f4b71Sopenharmony_ci}
86e41f4b71Sopenharmony_ci```
87e41f4b71Sopenharmony_ci
88e41f4b71Sopenharmony_ci
89e41f4b71Sopenharmony_ci```json
90e41f4b71Sopenharmony_ci{
91e41f4b71Sopenharmony_ci  "data": {
92e41f4b71Sopenharmony_ci    "index": 1
93e41f4b71Sopenharmony_ci  }
94e41f4b71Sopenharmony_ci}
95e41f4b71Sopenharmony_ci```
96e41f4b71Sopenharmony_ci**4 x 4 widget**
97e41f4b71Sopenharmony_ci
98e41f4b71Sopenharmony_ci![Swiper](figures/swiper.png)
99