npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

nuxt-hero

v0.5.1

Published

A full-featured hero slider Nuxt module with parallax, video backgrounds, overlay patterns, and customizable animations.

Readme

nuxt-hero

A full-featured hero slider Nuxt module with parallax, video backgrounds, overlay patterns, and customizable animations.

Features

  • Swiper-based slider with autoplay progress tracking
  • GSAP-powered parallax (background + content)
  • Video backgrounds (MP4, WebM, HLS via hls.js)
  • Overlay patterns (lines, dots, gradient, custom)
  • Dark mode support via @nuxtjs/color-mode
  • Built-in + animate.css animations
  • Thumbnail navigation previews
  • Vertical and horizontal layouts
  • @nuxt/icon for all icons (Lucide set)
  • Tailwind CSS v4

Installation

pnpm add nuxt-hero

Add the module to your nuxt.config.ts:

export default defineNuxtConfig({
  modules: ['nuxt-hero'],
})

Peer dependencies

Required:

pnpm add tailwindcss @tailwindcss/vite swiper @vueuse/nuxt @vueuse/core @nuxtjs/color-mode

Optional:

pnpm add @nuxt/image hls.js animate.css

Usage

The slider uses a composable + component pattern. Call useHeroSlider() to create the slider state, then pass it to <HeroSlider>:

<script setup>
const containerRef = useTemplateRef('containerRef')

const slides = [
  {
    bgSrc: 'https://example.com/photo.jpg',
    bgDarkSrc: 'https://example.com/photo-dark.jpg',
    thumbSrc: 'https://example.com/thumb.jpg',
    title: 'First Slide',
    animation: {
      enter: 'hero-animated hero-slideInUp',
      leave: 'hero-animated hero-slideOutDown',
    },
  },
  {
    bgSrc: 'https://example.com/video.mp4',
    title: 'Video Slide',
    config: {
      showVideoControls: true,
      videoLoop: false,
    },
  },
]

const slider = useHeroSlider(containerRef, slides, {
  swiperOptions: { autoplay: { delay: 5000 }, speed: 600 },
  enterAnimation: 'hero-animated hero-fadeIn',
  leaveAnimation: 'hero-animated hero-fadeOut',
})
</script>

<template>
  <HeroSlider
    ref="containerRef"
    :slider="slider"
    :slides="slides"
    :parallax="{ bg: true, content: true, speed: 0.5 }"
    :overlay-patterns="[{ type: 'lines', opacity: 0.1 }]"
    class="h-screen"
  >
    <template #slide="{ slide, isActive, isVideo, videoPlaying, videoToggle }">
      <div class="flex size-full items-center justify-center">
        <h1 class="text-5xl font-bold text-white">{{ slide.title }}</h1>
      </div>
    </template>
  </HeroSlider>
</template>

Props

HeroSlider

| Prop | Type | Default | Description | |------|------|---------|-------------| | slides | HeroSlide[] | required | Array of slide objects | | slider | UseHeroSliderReturn | required | Return value of useHeroSlider() | | enterAnimation | string | '' | Default enter animation class | | leaveAnimation | string | '' | Default leave animation class | | overlayPatterns | OverlayPattern[] | [{ type: 'lines', opacity: 0.1 }] | Stacked overlay patterns | | parallax | boolean \| ParallaxConfig | true | Parallax configuration | | imagePreset | string | '' | @nuxt/image preset name | | as | string | 'div' | Wrapper element tag | | ui | HeroSliderUI | {} | Class overrides for internal elements |

HeroSlide object

| Field | Type | Required | Description | |-------|------|----------|-------------| | bgSrc | string | yes | Background image or video URL | | bgDarkSrc | string | no | Dark mode background URL | | thumbSrc | string | no | Thumbnail for navigation preview | | title | string | no | Slide title | | poster | string | no | Poster frame for video backgrounds | | animation | { enter?, leave? } | no | Per-slide animation override | | config | SlideConfig | no | Per-slide display & media config |

SlideConfig

| Field | Type | Default | Description | |-------|------|---------|-------------| | showPagination | boolean | inherited | Show pagination when this slide is active | | showNavigation | boolean | inherited | Show navigation when this slide is active | | showProgress | boolean | inherited | Show progress bar when this slide is active | | showVideoControls | boolean | inherited | Show video controls (video slides only) | | videoLoop | boolean | false | Loop video playback | | mediaControlsOptions | MediaControlsOptions | — | VueUse useMediaControls options |

ParallaxConfig

| Field | Type | Default | Description | |-------|------|---------|-------------| | bg | boolean | true | Enable background parallax | | content | boolean | true | Enable content parallax | | speed | number | 0.125 | Parallax speed multiplier | | minOpacity | number | 0.7 | Minimum content opacity on scroll |

OverlayPattern

| Field | Type | Default | Description | |-------|------|---------|-------------| | type | 'lines' \| 'dots' \| 'gradient' \| 'custom' | required | Pattern type | | opacity | number | 0.15 | Pattern opacity | | color | string | 'black' | Pattern color | | css | string | — | Custom CSS background-image (for type: 'custom') |

HeroSliderUI

Class overrides for internal elements (Nuxt UI-style):

| Field | Description | |-------|-------------| | root | Root wrapper element | | swiper | Swiper container | | slide | Each SwiperSlide | | container | Slide inner container (.hero-slide) | | bg | Slide background layer (.hero-slide-bg) | | controls | UI controls overlay (pagination, navigation, progress) | | progress | Autoplay progress bar track |

Slots

| Slot | Props | Description | |------|-------|-------------| | slide | { slide, index, isActive, animationClass, isVideo, videoPlaying, videoDuration, videoCurrentTime, videoWaiting, videoEnded, videoMuted, videoVolume, videoToggle, videoSeek, videoSetVolume, videoToggleMute } | Slide content | | pagination | { activeIndex, snapIndex, totalSnaps, total, progress, goTo, vertical, autoplayEnabled } | Custom pagination | | navigation | { prev, next, activeIndex, slides, vertical } | Custom navigation | | overlay | { patterns, index, isActive, patternCSS, patternSize } | Custom overlay rendering | | video-controls | { playing, currentTime, duration, buffered, volume, muted, waiting, hls } | Custom video controls |

Built-in Animations

Use with the hero-animated base class:

  • hero-fadeIn / hero-fadeOut
  • hero-slideInUp / hero-slideOutDown
  • hero-slideInRight / hero-slideInLeft
  • hero-zoomIn / hero-zoomOut

Or use animate.css classes (install animate.css peer dependency).

Module Options

export default defineNuxtConfig({
  hero: {
    prefix: 'Hero',      // Component name prefix
    colorMode: true,      // Enable @nuxtjs/color-mode
    icon: true,           // Enable @nuxt/icon
    defaultVolume: 0,     // Default volume for video backgrounds (0-1)
  },
})

Composables

useHeroSlider(containerRef, slides, options?)

Core slider composable — creates and manages all slider state. Must be called in <script setup> and its return value passed to <HeroSlider> via the slider prop.

Parameters:

  • containerRef — Template ref for the root slider element (used for hover detection and GSAP scoping)
  • slides — Reactive array of HeroSlide objects
  • optionsUseHeroSliderOptions:

| Option | Type | Default | Description | |--------|------|---------|-------------| | swiperOptions | SwiperOptions | {} | Swiper configuration (autoplay.delay, speed, effect, direction, etc.) | | enterAnimation | string | '' | Default enter animation class | | leaveAnimation | string | '' | Default leave animation class | | showPagination | boolean | true | Show pagination dots | | showNavigation | boolean | true | Show navigation arrows | | showProgress | boolean | true | Show progress bar | | showVideoControls | boolean | true | Show video controls overlay |

Returns: UseHeroSliderReturn with navigation, slide state, autoplay, video controls, and hover state.

useGSAP(callback?, options?)

Vue composable wrapping gsap.context() for safe, scoped GSAP animations with automatic cleanup.

useHls(videoEl, src, options?)

HLS video playback composable — dynamically loads hls.js, with Safari native fallback.

Project Structure

src/runtime/
  components/
    slider/          # Core slider
      index.vue      # HeroSlider — main component
      HeroSlide.vue  # Individual slide with bg image/video
    video/           # Video playback controls
      HeroVideoControls.vue
      HeroVideoScrubber.vue
    navigation/      # Slide navigation UI
      HeroNavigation.vue
      HeroPagination.vue
  composables/
    useHeroSlider.ts # Core slider state, autoplay, video registration
    useGSAP.ts       # Scoped GSAP animations with cleanup
    useHls.ts        # HLS video playback
  utils.ts           # Shared utilities (video detection, patterns, formatting)
  types.ts           # TypeScript interfaces

Development

pnpm install
pnpm dev        # Start playground
pnpm test       # Run tests
pnpm build      # Build module
pnpm lint       # Lint with oxlint

License

MIT