---
name: "swiper-item"
mode: "component"
versionRequirements:
  - { name: "Base Library", version: "2.10.0" }
title: "swiper-item - Swiper view container child item"
---

## swiper-item

> [VERSION] Base Library >= 2.10.0

### Description

Child item of the swiper container; can only be used inside the swiper component

### Props

| Property | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `item-id` | `string` | No | `""` | Identifier for this slide |

### Examples

#### Basic usage

*index.tyml*

```xml
// index.tyml
<swiper class="swiper" autoplay="{{true}}" interval="{{3000}}">
  <swiper-item>
    <view class="swiper-content" style="background-color: #e6f7ff;">
      <text>Page 1</text>
    </view>
  </swiper-item>
  <swiper-item>
    <view class="swiper-content" style="background-color: #fff7e6;">
      <text>Page 2</text>
    </view>
  </swiper-item>
  <swiper-item>
    <view class="swiper-content" style="background-color: #f6ffed;">
      <text>Page 3</text>
    </view>
  </swiper-item>
</swiper>
```

*index.tyss*

```css
.swiper {
  height: 300rpx;
}
.swiper-content {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32rpx;
}
```

*index.js*

```javascript
Page({
  data: {},
});
```

#### Use with swiper for looping and indicator dots

*index.tyml*

```xml
// index.tyml
<swiper
  class="swiper"
  indicator-dots="{{true}}"
  circular="{{true}}"
  bind:change="onChange"
>
  <swiper-item>
    <view class="swiper-content bg-blue">Page A</view>
  </swiper-item>
  <swiper-item>
    <view class="swiper-content bg-green">Page B</view>
  </swiper-item>
</swiper>
<text>Current index: {{current}}</text>
```

*index.tyss*

```css
.swiper {
  height: 300rpx;
}
.swiper-content {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.bg-blue { background-color: #e6f7ff; }
.bg-green { background-color: #f6ffed; }
```

*index.js*

```javascript
Page({
  data: {
    current: 0,
  },
  onChange(e) {
    this.setData({ current: e.detail.current });
  },
});
```
