Skip to content

Props

The <Swiper> component is generic — the type parameter T is inferred from the :slides prop, so your slot props are fully typed with no casting.

vue
<script setup lang="ts">
import { Swiper } from "vue3-lite-swiper";

const slides = [
  { id: 1, title: "First" },
  { id: 2, title: "Second" },
  { id: 3, title: "Third" },
];
</script>

<template>
  <Swiper :slides="slides" :slide-width="300" :gap="16">
    <template #default="{ item }">
      <!-- item is typed as { id: number; title: string } -->
      <div class="slide">{{ item.title }}</div>
    </template>
  </Swiper>
</template>

Props reference

PropTypeDefaultDescription
slidesT[]Required. The data array. Each element is passed as item in the default slot.
mode"fixed" | "auto""fixed"How slide widths and snap positions are resolved. See below.
slideWidthnumberSlide width in pixels. Required when mode="fixed".
gapnumber20Horizontal gap between slides, in pixels.
slidesPerSwipenumber1Slides to advance per navigation step.
loopbooleanfalseEnable seamless infinite looping.
autoPlaybooleanfalseAdvance automatically at a fixed interval.

mode

The mode prop controls how the swiper figures out each slide's width and where the snap positions land.

"fixed" — You provide slideWidth. Snap positions are computed mathematically without measuring the DOM. This is the fastest option and the right choice whenever every slide is the same width.

vue
<Swiper :slides="slides" mode="fixed" :slide-width="300" />

"auto" — The component measures each slide's rendered width via getBoundingClientRect() after mount. Use this when slide widths differ or are driven by CSS rather than a fixed pixel value.

vue
<Swiper :slides="slides" mode="auto" />

slideWidth is required in fixed mode

Omitting slideWidth while mode="fixed" logs an error and disables all snap navigation. Either pass slideWidth or switch to mode="auto".

Slots

default

Renders a single slide. It receives the typed slide data and its render index.

vue
<Swiper :slides="items">
  <template #default="{ item, index }">
    <!-- item is typed as T -->
    <!-- index is the render position (may differ from the original when loop is active) -->
  </template>
</Swiper>
Slot propTypeDescription
itemTThe slide's data, typed from your array.
indexnumberRender position. When loop is enabled the component rotates the array internally, so this may not match the original array index.

Need an imperative handle?

Pair these props with the methods API to build pagination dots, prev/next buttons, or autoplay controls.

Released under the MIT License.