Skip to content

API Reference ​

Hooper Component ​

Props ​

PropTypeDefaultDescription
itemsToShownumber1Number of slides to display at once
itemsToSlidenumber1Number of slides to move per navigation
initialSlidenumber0Index of the initial slide
infiniteScrollbooleanfalseEnable infinite scrolling
centerModebooleanfalseCenter the current slide
verticalbooleanfalseEnable vertical sliding
rtlboolean | nullnullEnable RTL mode (null for auto-detection)
autoPlaybooleanfalseEnable auto-play
playSpeednumber2000Auto-play interval in milliseconds
mouseDragbooleantrueEnable mouse drag
touchDragbooleantrueEnable touch drag
wheelControlbooleantrueEnable mouse wheel control
keysControlbooleantrueEnable keyboard control
shortDragbooleantrueAllow short drag to trigger slide
transitionnumber300Transition duration in milliseconds
hoverPausebooleantruePause auto-play on hover
trimWhiteSpacebooleanfalseTrim whitespace at the edges
settingsobject{}Settings object (can include breakpoints)
groupstring | nullnullGroup name for synchronized carousels

Slots ​

SlotDescription
defaultSlide content (use <Slide> components)
hooper-addonsAddon components (Navigation, Pagination, Progress)

Methods ​

Access methods via template ref:

vue
<script setup lang="ts">
import { ref } from "vue";
import { Hooper, Slide } from "@wattanx/hooper-vue3";

const hooperRef = ref<InstanceType<typeof Hooper> | null>(null);

const goToSlide = (index: number) => {
  hooperRef.value?.slideTo(index);
};
</script>

<template>
  <Hooper ref="hooperRef">
    <Slide>Slide 1</Slide>
    <Slide>Slide 2</Slide>
    <Slide>Slide 3</Slide>
  </Hooper>
</template>
MethodDescription
slideTo(index: number)Slide to a specific index
slideNext()Slide to the next slide
slidePrev()Slide to the previous slide
update()Update the carousel (recalculates dimensions)
restart()Restart the carousel
restartTimer()Restart the auto-play timer

Events ​

EventPayloadDescription
beforeSlide{ currentSlide: number, slideTo: number }Emitted before sliding starts
slide{ currentSlide: number, slideFrom: number }Emitted during sliding
afterSlide{ currentSlide: number }Emitted after sliding completes
updated{ containerWidth, containerHeight, slideWidth, slideHeight, settings }Emitted when carousel is updated
loaded-Emitted when carousel is initialized
vue
<script setup lang="ts">
import { Hooper, Slide } from "@wattanx/hooper-vue3";

const onBeforeSlide = (payload: { currentSlide: number; slideTo: number }) => {
  console.log(`Sliding from ${payload.currentSlide} to ${payload.slideTo}`);
};

const onAfterSlide = (payload: { currentSlide: number }) => {
  console.log(`Now on slide ${payload.currentSlide}`);
};
</script>

<template>
  <Hooper @before-slide="onBeforeSlide" @after-slide="onAfterSlide">
    <Slide>Slide 1</Slide>
    <Slide>Slide 2</Slide>
    <Slide>Slide 3</Slide>
  </Hooper>
</template>

Slide Component ​

Props ​

PropTypeDefaultDescription
durationnumber0Custom auto-play duration for this slide (ms). When set to 0, uses the carousel's playSpeed.

CSS Classes ​

The Slide component automatically applies the following CSS classes:

ClassDescription
.is-activeApplied to slides within the visible range
.is-currentApplied to the current (main) slide
.is-prevApplied to slides immediately before the visible range
.is-nextApplied to slides immediately after the visible range
.is-cloneApplied to cloned slides (used in infinite scroll mode)

Pagination Component ​

Props ​

PropTypeDefaultDescription
mode'indicator' | 'fraction''indicator'Display mode - dots or fraction (e.g., "1/3")

The Navigation component provides previous/next buttons. It automatically adapts to vertical and RTL modes.

Slots ​

SlotDescription
hooper-prevCustom content for the previous button
hooper-nextCustom content for the next button
vue
<template>
  <Hooper>
    <Slide>Slide 1</Slide>
    <Slide>Slide 2</Slide>
    <Slide>Slide 3</Slide>

    <template #hooper-addons>
      <Navigation>
        <template #hooper-prev>
          <span>Previous</span>
        </template>
        <template #hooper-next>
          <span>Next</span>
        </template>
      </Navigation>
    </template>
  </Hooper>
</template>

Progress Component ​

The Progress component displays a progress bar indicating the current position in the carousel. No additional props are required.