Carousel
The Carousel component is a slideshow for cycling through a set of elements — images or text like - a carousel, referred to as slides, by sequentially displaying a subset of one or more slides. One slide is displayed at a time, and users can activate a next or previous slide control that hides the current slide and "rotates" the next or previous slide into view. The component implements the W3C ARIA APG Carousel Pattern.
Examples
Base
Here is a basic example of a carousel with some slides.
Indicators
Alongside the previous/next controls, slide indicators can be activated using the indicators
prop. Indicators allow the user to jump directly to a particular slide.The position can be set with the indicatorPosition
and indicatorInside
props to display the indicators at the top or bottom and inside or outside the slide. If there is more than one style defined for the indicators in a theme, the style can be customised by using the indicatorStyle
prop.
Carousel List
The component is capable of displaying and rotating more than one slide at a time. Therefore, the items-to-show
and items-to-list
props can be used to specify the number of items to be shown and rotated at once.
Slideshow
Using the indicators
slot, the indicators can be further customised to create a custom style like a picture gallery slideshow. Click on the slide to open the gallery mode.
Autoplay
Using the autoplay
prop, the carousel will run automatically. The interval
prop can be used to set the cycle speed. Moving focus to any of the carousel content, including the tab elements, pauses automatic rotation, when the pause-hover
prop is set. If operating system preferences have been set for reduced motion or disabling animations, the auto-rotation is initially paused.
Accessibility Note:
When using autoplay, users must be able to stop and start slide rotation, which is an essential aspect of carousel accessibility for a variety of people with disabilities. People with low vision or a cognitive disability that affects visual processing or reading benefit from being able to control slide rotation so that they have enough time to explore slide content.
Carousel component
A Slideshow for cycling images in confined spaces.
<o-carousel></o-carousel>
Props
Prop name | Description | Type | Values | Default |
---|---|---|---|---|
ariaAutoplayPauseLabel | Accessibility autoplay pause button aria label | string | - | From config: carousel: { |
ariaAutoplayResumeLabel | Accessibility autoplay resume button aria label | string | - | From config: carousel: { |
ariaNextLabel | Accessibility next button aria label | string | - | From config: carousel: { |
ariaPreviousLabel | Accessibility previous button aria label | string | - | From config: carousel: { |
arrows | Show next / prev arrows | boolean | - | From config: carousel: { |
arrowsHover | Show next / prev arrows only on hover | boolean | - | From config: carousel: { |
autoplay | Move item automaticalls after interval | boolean | - | false |
breakpoints | Define these props for different screen sizes | Record<number, any> | - | {} |
dragable | Enable drag mode | boolean | - | true |
iconAutoplayPause | Icon name for autoplay pause button | string | - | From config: carousel: { |
iconAutoplayResume | Icon name for autoplay resume button | string | - | From config: carousel: { |
iconNext | Icon name for next button | string | - | From config: carousel: { |
iconPack | Icon pack to use | string | mdi , fa , fas and any other custom icon pack | From config: carousel: { |
iconPrev | Icon name for previous button | string | - | From config: carousel: { |
iconSize | Icon size | string | small , medium , large | From config: carousel: { |
indicatorInside | Place indicators inside the carousel | boolean | - | false |
indicatorPosition | Position of the indicator - depends on used theme | string | - | From config: carousel: { |
indicatorStyle | Style of the indicator - depends on used theme | string | - | From config: carousel: { |
indicators | Enable indicators | boolean | - | true |
interval | Timer interval for autoplay | number | - | From config: carousel: { |
itemsToList | Number of items to switch at once | number | - | From config: carousel: { |
itemsToShow | Number of items to show at once | number | - | From config: carousel: { |
v-model | The index of the current active element | number | - | 0 |
overlay | Show an overlay | boolean | - | false |
override | Override existing theme classes completely | boolean | - | |
pauseHover | Pause autoplay on hover | boolean | - | false |
repeat | Repeat from the beginning after reaching the end | boolean | - | false |
Events
Event name | Properties | Description |
---|---|---|
update:model-value | value number - updated modelValue prop | modelValue prop two-way binding |
change | value number - active index | on carousel slide change event |
click | event event - native event | on item click event |
Slots
Name | Description | Bindings |
---|---|---|
pause | Override the pause/resume button | autoplay boolean - if autoplay is activetoggle (): void - toggle autoplay |
arrow | Override the arrows | has-prev boolean - has prev arrow buttonprev (): void - switch to prev item functionhas-next boolean - has next arrow buttonnext (): void - switch to next item function |
default | Display carousel item | |
indicators | Override the indicators | active number - active indexswitch-to (idx: number): void - switch to item function |
indicator | Override the indicator elements | index index - indicator index |
overlay | Overlay element |
CarouselItem component
A Slideshow item used by the carousel.
<o-carousel-item></o-carousel-item>
Props
Prop name | Description | Type | Values | Default |
---|---|---|---|---|
clickable | Make item clickable | boolean | - | false |
override | Override existing theme classes completely | boolean | - |
Slots
Name | Description | Bindings |
---|---|---|
default | Default content |
Class Inspector
Class prop | Description | Props | Suffixes | |
---|---|---|---|---|
rootClass | Class of the root element. | |||
overlayClass | Class of the root element when overlay. | overlay | ||
wrapperClass | Class of the inner wrapper element. | |||
itemsClass | Class of items container element. | |||
itemsDraggingClass | Class of items container element when dragging. | dragable | ||
iconClass | Class of icon button elements. | |||
iconPrevClass | Class of prev icon button element. | |||
iconNextClass | Class of next icon button element. | |||
iconAutoplayClass | Class of autoplay icon button element. | |||
indicatorsClass | Class of indicators tablist element. | |||
indicatorsInsideClass | Class of indicators tablist element when inside. | indicatorInside | ||
indicatorsPositionClass | Class of indicators tablist element with position. | indicatorPosition | ||
indicatorClass | Class of indicator tab element. | |||
indicatorItemClass | Class of indicator item element. | |||
indicatorItemActiveClass | Class of indicator item element when active. | |||
indicatorItemStyleClass | Class of indicator item element to separate different styles. | indicatorStyle | ||
▷ itemClass | Class of item element. | |||
▷ itemActiveClass | Class of item element when active. | |||
▷ itemClickableClass | Class of item element when clickable. | clickable |
Sass variables
Current theme ➜ Oruga
SASS Variable | Default |
---|---|
$carousel-arrow-background | var(--#{$prefix}white) |
$carousel-arrow-color | var(--#{$prefix}primary) |
$carousel-arrow-icon-spaced | 1.5rem |
$carousel-arrow-top | 50% |
$carousel-arrow-size | 1.5rem |
$carousel-arrow-border-radius | var( --#{$prefix}base-border-radius-rounded) |
$carousel-arrow-border | 1px solid $carousel-arrow-background |
$carousel-arrow-transition | var(--#{$prefix}transition-duration) var(--#{$prefix}transition-timing) |
$carousel-autoplay-top | 1em |
$carousel-autoplay-left | $carousel-arrow-icon-spaced |
$carousel-autoplay-right | unset |
$carousel-autoplay-bottom | unset |
$carousel-indicators-background | rgba(var(--#{$prefix}white), 0.5) |
$carousel-indicators-padding | 0.5rem |
$carousel-indicator-margin | 0 0.5rem 0 0 |
$carousel-indicator-color | var(--#{$prefix}primary) |
$carousel-indicator-background | var(--#{$prefix}white) |
$carousel-indicator-border | 1px solid $carousel-indicator-color |
$carousel-indicator-active-background | $carousel-indicator-color |
$carousel-indicator-active-border | 1px solid $carousel-indicator-color |
$carousel-indicator-transition | var(--#{$prefix}transition-duration) var(--#{$prefix}transition-timing) |
$carousel-indicator-size | 10px |
$carousel-indicator-dots-border-radius | var( --#{$prefix}base-border-radius) |
$carousel-indicator-lines-height | 5px |
$carousel-indicator-lines-width | 25px |
$carousel-items-transition | all var(--#{$prefix}transition-duration) var(--#{$prefix}transition-timing) 0s |
$carousel-item-border | 2px solid transparent |
$carousel-overlay-background | hsla(0, 0%, 4%, 0.86) |
$carousel-overlay-zindex | 40 |
See ➜ 📄 Full scss file
Current theme ➜ Bulma
SASS Variable | Default |
---|---|
$carousel-arrow-icon-spaced | 1.5rem |
$carousel-arrow-top | 50% |
$carousel-indicator-spaced | 0.5rem |
$carousel-overlay-z | 40 |
$carousel-arrow-background | css.getVar("scheme-main") |
$carousel-arrow-color | css.getVar("primary") |
$carousel-indicator-background | rgba(css.getVar("scheme-invert"), 0.5) |
$carousel-indicator-border | css.getVar("scheme-main") |
$carousel-indicator-color | css.getVar("primary") |
$carousel-overlay-background | hsla( css.getVar(scheme-h), css.getVar(scheme-s), css.getVar(scheme-invert-l), 0.86) |
See ➜ 📄 Full scss file
Current theme ➜ Bootstrap
The theme does not have any custom variables for this component.