Swiper - 图1

Swiper Svelte Component

Framework7 comes with powerful and most modern touch slider ever - Swiper Slider with super flexible configuration and lot, lot of features.

Swiper Svelte component represents Framework7’s Swiper component.

Swiper Components

There are following components included:

  • Swiper - main swiper element, which contains slides and paginations
  • SwiperSlide - a single slide element. Could contain any HTML inside

Swiper Properties

PropTypeDefaultDescription
<Swiper> properties
initbooleantrueInitializes Swiper
paramsobjectObject with Swiper API parameters
paginationbooleanEnables pagination
scrollbarbooleanEnables scrollbar
navigationbooleanEnables prev/next navigation buttons
<SwiperSlide> properties
zoombooleanAdds additional slide inner wrapping required for zoom-in functionality (should be also enabled via params on Swiper initialization)

Swiper Slots

Swiper Svelte component (<Swiper>) has additional slots for custom elements:

  • before-wrapper - element will be inserted right before <div class="swiper-wrapper"> element
  • after-wrapper - element will be inserted right after <div class="swiper-wrapper"> element
  1. <Swiper>
  2. <div slot="before-wrapper">Before Wrapper</div>
  3. <div slot="after-wrapper">After Wrapper</div>
  4. <SwiperSlide>Default Slot</SwiperSlide>
  5. </Swiper>
  6. <!-- Renders to: -->
  7. <div class="swiper-container">
  8. <div>Before Wrapper</div>
  9. <div class="swiper-wrapper">
  10. <div class="swiper-slide">Default Slot</div>
  11. </div>
  12. <div>After Wrapper</div>
  13. </div>

Access To Swiper Instance

If you use automatic initalization to init Swiper (with init={true} prop) and need to use Swiper API you can access its initialized instance by accessing .swiper component’s property.

Examples

Minimal layout

  1. <Swiper>
  2. <SwiperSlide>Slide 1</SwiperSlide>
  3. <SwiperSlide>Slide 2</SwiperSlide>
  4. <SwiperSlide>Slide 3</SwiperSlide>
  5. </Swiper>

With all controls

  1. <Swiper pagination navigation scrollbar>
  2. <SwiperSlide>Slide 1</SwiperSlide>
  3. <SwiperSlide>Slide 2</SwiperSlide>
  4. <SwiperSlide>Slide 3</SwiperSlide>
  5. </Swiper>

With additional parameters

You can pass any additional Swiper API parameters using params property:

  1. <Swiper navigation params={{speed:500, slidesPerView: 3, spaceBetween: 20}}>
  2. <SwiperSlide>Slide 1</SwiperSlide>
  3. <SwiperSlide>Slide 2</SwiperSlide>
  4. <SwiperSlide>Slide 3</SwiperSlide>
  5. <SwiperSlide>Slide 4</SwiperSlide>
  6. <SwiperSlide>Slide 5</SwiperSlide>
  7. <SwiperSlide>Slide 6</SwiperSlide>
  8. </Swiper>

← Swipeout

Tabs →