Preview Updated 2026-05-10

Carousel

Horizontal carousel for images or custom content, with autoplay, looping, indicators, and prev/next controls.

Basic usage

items accepts an { src, alt } list to render images; autoplay plus interval advances slides automatically and pauses on hover.

背景
<script setup lang="ts">
import { CfCarousel, type CarouselItem } from '@chufix-design/vue';

const items: CarouselItem[] = [
  { src: 'https://images.unsplash.com/photo-1503023345310-bd7c1de61c7d?w=800&h=300&fit=crop', alt: '场景 1' },
  { src: 'https://images.unsplash.com/photo-1518837695005-2083093ee35b?w=800&h=300&fit=crop', alt: '场景 2' },
  { src: 'https://images.unsplash.com/photo-1500530855697-b586d89ba3ee?w=800&h=300&fit=crop', alt: '场景 3' },
];
</script>

<template>
  <CfCarousel :items="items" autoplay :interval="3000" />
</template>
<script setup>
import { CfCarousel } from '@chufix-design/vue';

const items= [
  { src: 'https://images.unsplash.com/photo-1503023345310-bd7c1de61c7d?w=800&h=300&fit=crop', alt: '场景 1' },
  { src: 'https://images.unsplash.com/photo-1518837695005-2083093ee35b?w=800&h=300&fit=crop', alt: '场景 2' },
  { src: 'https://images.unsplash.com/photo-1500530855697-b586d89ba3ee?w=800&h=300&fit=crop', alt: '场景 3' },
];
</script>

<template>
  <CfCarousel :items="items" autoplay :interval="3000" />
</template>
<CfCarousel items={items} autoplay interval={3000} />
<CfCarousel items={items} autoplay interval={3000} />

API

PropTypeDefaultDescription
itemsCarouselItem[]Carousel item list
value / modelValuenumberControlled current index
defaultValuenumber0Uncontrolled initial index
autoplaybooleanfalseAutoplay
intervalnumber4000Autoplay interval (ms)
loopbooleantrueLoop playback
controlsbooleantrueShow prev/next buttons
indicatorsbooleantrueShow bottom indicators
size'sm' | 'md' | 'lg''md'Viewport height tier

Events: onChange(index) — fires when the current index changes.

反馈与讨论

Carousel · Discussion

0
0 / 600
一键发送
正在加载评论...