Veil UI
Components

Image Carousel

A looping carousel of captioned images.

Installation

$ npx veil-ui@latest add image-carousel

Usage

import { ImageCarousel } from "@/components/ui/image-carousel";

<ImageCarousel images={[{ src: "/one.jpg", alt: "First", caption: "Dolomites" }]} />;

Examples

Basic

Mountains at sunrise
Dolomites, Italy
Cabin beside a lake
Lake Bled, Slovenia
Snowy mountain peak
Swiss Alps

Compact

Mountains at sunrise
Dolomites, Italy
Cabin beside a lake
Lake Bled, Slovenia
Snowy mountain peak
Swiss Alps

API reference

The package exports image-carousel along with its composable parts. It forwards standard attributes to its root element; see the examples above for the component-specific props.

Accessibility

  • Media players use native <video> and <audio> controls with accessible labels.
  • Images require meaningful alt text; clickable thumbnails are buttons named Play <title>.
  • Decorative play overlays, durations and icons are hidden from assistive technology.

Vue and plain HTML

This component also ships for Vue (Reka UI) and plain HTML. Install it with npx veil-ui add image-carousel --framework vue or switch the framework in components.json.

<script setup lang="ts">
import {
  Carousel,
  CarouselContent,
  CarouselItem,
  CarouselNext,
  CarouselPrevious,
} from "@/components/ui/carousel";

interface ImageCarouselItem {
  src: string;
  alt: string;
  caption?: string;
}

const props = withDefaults(
  defineProps<{
    images: ImageCarouselItem[];
    class?: string;
    label?: string;
  }>(),
  { label: "Image carousel" },
);
</script>

<template>
  <Carousel :class="props.class" :label="label">
    <CarouselContent>
      <CarouselItem v-for="image in images" :key="image.src">
        <figure>
          <img
            :src="image.src"
            :alt="image.alt"
            loading="lazy"
            class="aspect-video w-full rounded-lg object-cover"
          />
          <figcaption
            v-if="image.caption"
            class="mt-2 text-center text-xs text-muted-foreground"
          >
            {{ image.caption }}
          </figcaption>
        </figure>
      </CarouselItem>
    </CarouselContent>
    <CarouselPrevious />
    <CarouselNext />
  </Carousel>
</template>

On this page