1.0.2 ⢠Published 7 months ago
@sr3pp/nuxt-splide v1.0.2
Nuxt Splide
šø A zero-config Splide integration for Nuxt 3 ā with built-in themes, custom theme support, and runtime switching.
⨠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
variantprop - ā
Zero-config install via
nuxi module add
š Quick Start
npx nuxi module add @nuxt/splideThen 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
| Option | Type | Description |
|---|---|---|
defaultTheme | string | Sets the default splide style |
customTheme | string | Path to a custom theme CSS file in your project |
themes | string[] | List of available themes to register |
šØ Theming
ā Built-in themes:
defaultskybluesea-greensr3pp(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.splideto 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!