Vue 3 wrapper component for Swiper.js carousel library providing bridge to official swiper/vue implementation
npx @tessl/cli install tessl/npm-vue-awesome-swiper@5.0.0Vue Awesome Swiper is a Vue 3 wrapper component for the Swiper.js carousel/slider library. It serves as a bridge package that re-exports all functionality from the official swiper/vue implementation while providing a Vue plugin interface for easy global registration.
npm install swiper vue-awesome-swiperAll swiper/vue exports available:
import {
Swiper,
SwiperSlide,
useSwiper,
useSwiperSlide
} from "vue-awesome-swiper";
// Complete re-export: ALL swiper/vue functionality is available
import * as SwiperVue from "vue-awesome-swiper";Default import (plugin):
import VueAwesomeSwiper from "vue-awesome-swiper";CommonJS:
const { Swiper, SwiperSlide, useSwiper, useSwiperSlide } = require("vue-awesome-swiper");Important: This package re-exports everything from swiper/vue via export * from 'swiper/vue'. Any API available in swiper/vue is also available from vue-awesome-swiper.
Local Component Registration:
<template>
<swiper :modules="modules" :pagination="{ clickable: true }">
<swiper-slide>Slide 1</swiper-slide>
<swiper-slide>Slide 2</swiper-slide>
<swiper-slide>Slide 3</swiper-slide>
</swiper>
</template>
<script>
import SwiperClass, { Pagination } from 'swiper';
import { Swiper, SwiperSlide } from 'vue-awesome-swiper';
// Import Swiper styles
import 'swiper/css';
import 'swiper/css/pagination';
export default {
components: {
Swiper,
SwiperSlide
},
setup() {
return {
modules: [Pagination]
};
}
};
</script>Global Plugin Registration:
import { createApp } from 'vue';
import VueAwesomeSwiper from 'vue-awesome-swiper';
import 'swiper/css';
const app = createApp();
app.use(VueAwesomeSwiper);Vue Awesome Swiper is built around a simple bridge architecture:
swiper/vue using export * from 'swiper/vue' - this includes components, composables, types, and utilitiesinstall method for global component registrationSwiper and SwiperSlide components through both named and default exportsvue-awesome-swiper are functionally identical to imports from swiper/vueThis package provides complete access to the swiper/vue API through export * from 'swiper/vue'. This means:
// These imports are functionally identical:
import { Swiper, SwiperSlide, useSwiper, useSwiperSlide } from "vue-awesome-swiper";
import { Swiper, SwiperSlide, useSwiper, useSwiperSlide } from "swiper/vue";
// ALL swiper/vue exports are available, including but not limited to:
// - Swiper component with all props, events, and slots
// - SwiperSlide component with reactive slot props
// - useSwiper() composable for accessing Swiper instance
// - useSwiperSlide() composable for slide-specific data
// - All TypeScript types and interfaces from swiper/vue
// - Any additional utilities or helpers from swiper/vueAPI Coverage: According to the original repository documentation, "All options and events of the original Swiper are supported" through this re-export mechanism.
Main carousel container component with full Swiper.js functionality and Vue 3 integration.
interface SwiperComponent {
// Component props (all Swiper configuration options)
modules?: SwiperModule[];
allowTouchMove?: boolean;
slidesPerView?: number | 'auto';
autoplay?: AutoplayOptions | boolean;
navigation?: NavigationOptions | boolean;
pagination?: PaginationOptions | boolean;
scrollbar?: ScrollbarOptions | boolean;
// ... all other Swiper options
// Component events
onSwiper?: (swiper: SwiperInstance) => void;
onSlideChange?: (swiper: SwiperInstance) => void;
onTransitionStart?: (swiper: SwiperInstance) => void;
onTransitionEnd?: (swiper: SwiperInstance) => void;
// ... all other Swiper events
}
// Available slots
interface SwiperSlots {
'container-start'?: () => VNode[];
'wrapper-start'?: () => VNode[];
default?: () => VNode[];
'wrapper-end'?: () => VNode[];
'container-end'?: () => VNode[];
}Individual slide component for carousel content with reactive slot props.
interface SwiperSlideComponent {
// Slot props available to slide content
slotProps: {
isActive: boolean;
isVisible: boolean;
isDuplicate: boolean;
isPrev: boolean;
isNext: boolean;
};
}Provides access to the Swiper instance within Swiper component context.
/**
* Access the Swiper instance from within a Swiper component
* @returns Swiper instance or null if not within Swiper context
*/
function useSwiper(): SwiperInstance | null;Provides access to slide-specific data and state within SwiperSlide component context.
/**
* Access slide-specific data from within a SwiperSlide component
* @returns Slide data object or null if not within SwiperSlide context
*/
function useSwiperSlide(): {
isActive: Ref<boolean>;
isVisible: Ref<boolean>;
isDuplicate: Ref<boolean>;
isPrev: Ref<boolean>;
isNext: Ref<boolean>;
} | null;Vue plugin interface for global component registration.
interface VueAwesomeSwiperPlugin {
Swiper: typeof SwiperComponent;
SwiperSlide: typeof SwiperSlideComponent;
install(app: App): void;
}
/**
* Install vue-awesome-swiper as a Vue plugin
* Registers Swiper and SwiperSlide components globally
* @param app - Vue application instance
*/
function install(app: App): void;Vue Awesome Swiper works with Swiper's modular architecture. Modules must be imported from the swiper package and registered:
import SwiperClass, {
Navigation,
Pagination,
Scrollbar,
Autoplay,
EffectFade
} from 'swiper';
// Register modules
SwiperClass.use([Navigation, Pagination, Scrollbar, Autoplay, EffectFade]);Available Modules:
Navigation - Previous/next buttonsPagination - Dots/bullets/numbers paginationScrollbar - Scrollbar controlAutoplay - Automatic slide progressionEffectFade, EffectCube, EffectCoverflow, EffectFlip, EffectCards, EffectCreative - Transition effectsLazy - Lazy loading for imagesZoom - Zoom functionalityKeyboard - Keyboard controlMousewheel - Mouse wheel controlVirtual - Virtual slidesController - Multi-swiper synchronizationThumbs - Thumbnail navigationHistory - Browser history integrationHashNavigation - Hash navigationParallax - Parallax effectsManipulation - Dynamic slide manipulationFreeMode - Free mode scrollinginterface SwiperInstance {
// Core methods
slideNext(speed?: number, runCallbacks?: boolean): void;
slidePrev(speed?: number, runCallbacks?: boolean): void;
slideTo(index: number, speed?: number, runCallbacks?: boolean): void;
update(): void;
destroy(deleteInstance?: boolean, cleanStyles?: boolean): void;
// Properties
activeIndex: number;
realIndex: number;
slides: HTMLElement[];
isBeginning: boolean;
isEnd: boolean;
// Navigation
allowSlideNext: boolean;
allowSlidePrev: boolean;
allowTouchMove: boolean;
}
interface AutoplayOptions {
delay?: number;
disableOnInteraction?: boolean;
reverseDirection?: boolean;
stopOnLastSlide?: boolean;
waitForTransition?: boolean;
}
interface NavigationOptions {
nextEl?: string | HTMLElement;
prevEl?: string | HTMLElement;
hideOnClick?: boolean;
disabledClass?: string;
hiddenClass?: string;
}
interface PaginationOptions {
el?: string | HTMLElement;
type?: 'bullets' | 'fraction' | 'progressbar' | 'custom';
clickable?: boolean;
dynamicBullets?: boolean;
bulletClass?: string;
bulletActiveClass?: string;
}
interface ScrollbarOptions {
el?: string | HTMLElement;
hide?: boolean;
draggable?: boolean;
snapOnRelease?: boolean;
}
type SwiperModule = typeof Navigation | typeof Pagination | typeof Scrollbar | typeof Autoplay;Swiper requires CSS imports for styling:
// Core Swiper styles (required)
import 'swiper/css';
// Module-specific styles (as needed)
import 'swiper/css/navigation';
import 'swiper/css/pagination';
import 'swiper/css/scrollbar';
import 'swiper/css/autoplay';
import 'swiper/css/effect-fade';
// ... other module stylesswiper/vue implementationswiper/vue through export * from 'swiper/vue' - this package is a completely transparent bridgevue-awesome-swiper imports with swiper/vue imports directly with no code changes requiredvue-awesome-swiper are "exactly equivalent to" imports from swiper/vueCommon issues and solutions:
swiper package and registered with SwiperClass.use()swiper and vue-awesome-swiper are installed as dependencies