1.0.2 • Published 3 months ago

@sr3pp/nuxt-splide v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

Nuxt Splide

šŸ“ø A zero-config Splide integration for Nuxt 3 — with built-in themes, custom theme support, and runtime switching.

npm version Nuxt Module


✨ Features

  • āœ… Auto-installs and registers @splidejs/vue-splide
  • āœ… Auto-imports <SplideContainer> and <SplideSlide> globally
  • āœ… Built-in support for official Splide themes (default, skyblue, sea-green)
  • āœ… Custom theme support via your own CSS
  • āœ… Runtime variant switching using the variant prop
  • āœ… Zero-config install via nuxi module add

šŸš€ Quick Start

npx nuxi module add @nuxt/splide

Then use it immediately:

<template>
  <SplideContainer :options="{ perPage: 2 }">
    <SplideSlide v-for="n in 4" :key="n">
      Slide {{ n }}
    </SplideSlide>
  </SplideContainer>
</template>

āœ… No manual imports required.


āš™ļø Configuration

Add your configuration to nuxt.config.ts under the splide key. You can define multiple themes and a default one:

export default defineNuxtConfig({
  modules: ['@nuxt/splide'],
  splide: {
    themes: ['default', 'skyblue', 'sea-green', 'sr3pp'], // multiple available themes
    defaultTheme: 'skyblue', // sets the default one
    customTheme: '~/assets/css/my-splide-theme.css' // optional
  }
})

Options

OptionTypeDescription
defaultThemestringSets the default splide style
customThemestringPath to a custom theme CSS file in your project
themesstring[]List of available themes to register

šŸŽØ Theming

āœ… Built-in themes:

  • default
  • skyblue
  • sea-green

  • sr3pp (example)

  • nuxt (example)

These load the official Splide themes and apply them globally.


āœ³ļø Custom Themes

You can define your own themes using scoped CSS like this:

/* assets/css/my-splide-theme.css */
.splide--mytheme .splide__arrow {
  background: linear-gradient(135deg, #8e44ad, #c0392b);
  color: white;
}

Then in nuxt.config.ts:

splide: {
  customTheme: '~/assets/css/my-splide-theme.css'
}

šŸ’” Tips

  • All your custom themes will extend official styles.
  • Style .splide--[variant] instead of .splide to isolate themes cleanly.
  • You can dynamically create your own themes inside a module like this one by compiling SCSS to src/css/ and exporting them.

šŸ“ File Structure Example

nuxt-splide/
ā”œā”€ā”€ src/
│   ā”œā”€ā”€ module.ts            # Nuxt module setup
│   ā”œā”€ā”€ runtime/
│   │   └── components/
│   │       ā”œā”€ā”€ Splide.vue
│   │       └── SplideSlide.vue
│   └── css/
│       └── sr3pp.css        # Compiled custom theme
ā”œā”€ā”€ themes/
│   ā”œā”€ā”€ utils/_tools.scss    # SCSS variables/mixins
│   └── sr3pp.scss           # SCSS theme source

šŸ“¦ Publishing

This module uses exports for Nuxt-style theme loading:

"exports": {
  "./css/sr3pp.css": "./src/css/sr3pp.css"
}

Users can reference themes as:

nuxt.options.css.push('nuxt-splide/css/sr3pp.css')

🪪 License

MIT


šŸ§‘ā€šŸŽØ Author

Created with ā¤ļø by @sr3pp

Feel free to contribute, fork, or use in your own Nuxt modules!

1.0.2

3 months ago

1.0.1

3 months ago

1.0.0

3 months ago