Carousel

Extended from PrimeVue Carousel

Basic example

This example shows a responsive carousel with six items, rendered as cards with an image and subtitle. Mobile sees one card at a time, which then increases to two and three as the viewport width increases.

No dots

When dots are turned off, the arrows are spaced out more but still appear below the carousel.

Customization

This example shows the ability to customize the gap between slides, the gap between the slides and the controls, 'peek' styling for cards on desktop and mobile, and the size and color of the arrow button icons.

Circular behavior

This setting allows the user to continue paging in one direction forever and the items from the beginning of the list will be repeated once the end of the list is reached. It's recommended to show the dots when the circular setting is enabled so the user knows when the end of the list is reached.

Unless paging is done in a rapid-fire succession (the carousel needs a split second to add more hidden items after a page transition completes), the next set of items will always appear to come from the same direction as all previous items, even when circling back to the beginning of the list.

Autoplay with circular behavior

This example shows autoplay behavior with circular mode enabled, to show a slideshow of images.

Pressing the Esc key will stop the autoplay and reset the carousel to the first item. This is an important accessibility feature for screen readers, because the contents of each new slide brought into view by autoplay are automatically read aloud, no matter where the user is on the page, which can be distracting while trying to read through another part of the page.

EsCarousel props

Name
arrowSize
Type
String
Default
"sm"
Description
Takes either "sm" or "lg". Small size is 24px, large size is 32px.
Name
autoPlay
Type
Boolean
Default
false
Description
If true, the carousel will automatically go to the next page after a set interval, determined by autoPlayInterval. The autoplay functionality can be stopped by pressing the Esc key.
Name
autoPlayInterval
Type
Number
Default
4000
Description
If autoPlay is true, this determines the number of milliseconds between transitions.
Name
breakpoints
Type
Object
Default
{}
Description
Allows you to specify how many items should be shown and how many items should scroll at each breakpoint. This object has optional keys of sm, md, lg, xl, and xxl. If a breakpoint is omitted, the values from the next-lowest defined breakpoint will be used. Each key points to an object where you can set numScroll (optional) and numVisible (required).
Name
circular
Type
Boolean
Default
true
Description
Whether the carousel should stop paging at either end or start over from the beginning.
Name
controlGap
Type
Number
Default
24
Description
The spacing, in pixels, between the carousel slides and the controls that appear below.
Name
items
Type
Array
Default
[]
Description
Required. The items to display in the carousel. Use the template #item to style the items.
Name
numScroll
Type
Number
Default
1
Description
The number of items to scroll on each page transition. This is also used as the default mobile value when using breakpoints.
Name
numVisible
Type
Number
Default
1
Description
The number of items visible at any one time. This is also used as the default mobile value when using breakpoints.
Name
peekDesktop
Type
string
Default
""
Description
Padding added to the right of the carousel on desktop viewports to give the rightmost card a peek or cut-off. Ex: "100px"; "6rem".
Name
peekMobile
Type
string
Default
""
Description
Same as peekDesktop but only applies to mobile viewports. Both must be set if peek should be applied to all viewports.
Name
showArrows
Type
Boolean
Default
true
Description
Whether to show the arrows below the carousel.
Name
showDots
Type
Boolean
Default
true
Description
Whether to show the dots below the carousel.
Name
slideGap
Type
Number
Default
16
Description
The spacing, in pixels, between each carousel slide.
Name
variant
Type
String
Default
"default"
Description
Takes either "default" or "brand". Default means gray arrows, brand means blue arrows.

EsCarousel events

Name
update
Parameters
value (Number)
Description
Emitted when the visible page of the carousel changes.