Back to Element Plus

Carousel

docs/en-US/component/carousel.md

2.13.76.8 KB
Original Source

Carousel

Loop a series of images or texts in a limited space

Basic usage

:::demo Combine el-carousel with el-carousel-item, and you'll get a carousel. Content of each slide is completely customizable, and you just need to place it inside el-carousel-item tag. By default the carousel switches when mouse hovers over an indicator. Set trigger to click, and the carousel switches only when an indicator is clicked.

carousel/basic

:::

Motion blur ^(2.6.0)

Add motion blur to infuse dynamism and smoothness into the carousel.

:::demo Enabling motion blur enhances the dynamism and smoothness of the carousel. By default, the motion-blur parameter is set to false, activating this feature and providing a visually engaging experience.

carousel/motion-blur

:::

Indicators

Indicators can be displayed outside the carousel

:::demo The indicator-position attribute determines where the indicators are located. By default they are inside the carousel, and setting indicator-position to outside moves them outside; setting indicator-position to none hides the indicators.

carousel/indicator

:::

Arrows

You can define when arrows are displayed

:::demo The arrow attribute determines when arrows are displayed. By default they appear when mouse hovers over the carousel. Setting arrow to always or never shows/hides the arrows permanently.

carousel/arrows

:::

Auto height

When the height of carousel is set to auto, the carousel height will be automatically set according to the height of the carousel item

:::demo

carousel/auto-height

:::

Card mode

When a page is wide enough but has limited height, you can activate card mode for carousels

:::demo Setting type to card activates the card mode. Apart from the appearance, the biggest difference between card mode and common mode is that clicking the slides at both sides directly switches the carousel in card mode.

carousel/card

:::

Vertical

By default, direction is horizontal. Let carousel be displayed in the vertical direction by setting direction to vertical.

:::demo

carousel/vertical

:::

NameDescriptionTypeDefault
heightheight of the carousel^[string]''
initial-indexindex of the initially active slide (starting from 0)^[number]0
triggerhow indicators are triggered^[enum]'hover' | 'click'hover
autoplaywhether automatically loop the slides^[boolean]true
intervalinterval of the auto loop, in milliseconds^[number]3000
indicator-positionposition of the indicators^[enum]'' | 'none' | 'outside'''
arrowwhen arrows are shown^[enum]'always' | 'hover' | 'never'hover
typetype of the Carousel^[enum]'' | 'card'''
card-scale ^(2.7.8)when type is card, scaled size of secondary cards^[number]0.83
loopdisplay the items in loop^[boolean]true
directiondisplay direction^[enum]'horizontal' | 'vertical'horizontal
pause-on-hoverpause autoplay when hover^[boolean]true
motion-blur ^(2.6.0)infuse dynamism and smoothness into the carousel^[boolean]false
NameDescriptionType
changetriggers when the active slide switches, it has two parameters, the one is the index of the new active slide, and other is index of the old active slide^[Function](current: number, prev: number) => boolean
NameDescriptionSubtags
defaultcustomize default contentCarousel-Item
MethodDescriptionType
activeIndex ^(2.7.8)active slide index^[number]
setActiveItemmanually switch slide, index of the slide to be switched to, starting from 0; or the name of corresponding el-carousel-item^[Function](index: string | number) => void
prevswitch to the previous slide^[Function]() => void
nextswitch to the next slide^[Function]() => void
NameDescriptionTypeDefault
namename of the item, can be used in setActiveItem^[string]''
labeltext content for the corresponding indicator^[string] / ^[number]''
NameDescription
defaultcustomize default content