Vue 3 Carousel Nuxt Module

1.1.6 · active · verified Tue Apr 21

vue3-carousel-nuxt is a Nuxt 3 module designed to seamlessly integrate the popular vue3-carousel component library into Nuxt 3 applications. It automates the setup process, registering the Carousel, Slide, Pagination, and Navigation components globally or with a user-defined prefix, and automatically includes the default carousel CSS styles, preventing duplicate imports. The current stable version is 1.1.6, with a recent history of active patch releases indicating ongoing maintenance and responsiveness to bug fixes since its initial release as v1.1.0. This module significantly simplifies the developer experience by abstracting away manual component registration and style management, allowing developers to focus directly on building interactive carousels within their Nuxt projects. Its primary differentiator is the deep integration with Nuxt's module system, providing a plug-and-play experience compared to manually adding and configuring the base vue3-carousel library.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to configure the `vue3-carousel-nuxt` module in `nuxt.config.ts` and effectively use the auto-imported carousel components with a custom prefix in a Vue template, alongside examples of styling overrides.

import { defineNuxtConfig } from 'nuxt';

// nuxt.config.ts
export default defineNuxtConfig({
  modules: [
    'vue3-carousel-nuxt' // Add the module to your Nuxt configuration
  ],
  carousel: {
    prefix: 'MyCustom' // Optional: prefix components to avoid naming conflicts
  }
});

// app.vue or a page component (e.g., pages/index.vue)
<template>
  <div class="container">
    <h1>Featured Items Carousel</h1>
    <MyCustomCarousel :items-to-show="1.5" :wrap-around="true" :transition="500">
      <MyCustomSlide v-for="slide in 8" :key="slide">
        <div class="carousel__item">Item {{ slide }}</div>
      </MyCustomSlide>

      <template #addons>
        <MyCustomNavigation />
        <MyCustomPagination />
      </template>
    </MyCustomCarousel>
  </div>
</template>

<style>
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
}
.carousel__item {
  min-height: 200px;
  width: 100%;
  background-color: #f0f0f0;
  color: #333;
  font-size: 24px;
  border-radius: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 10px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
/* Example of overriding default carousel styles */
.carousel__prev, .carousel__next {
  background-color: #fff;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  color: #333;
  width: 48px; /* Custom size */
  height: 48px; /* Custom size */
}
.carousel__pagination-button--active::after {
  background-color: #007bff; /* Custom active pagination dot color */
}
</style>

view raw JSON →