Carousel is deprecated in SWAN v3.25.0.
Use AdaptiveCarousel instead, which has improved performance and increased consistency for customers. See Deprecation for more information.
Carousel is only available in the React API for SWAN.
Carousel is deprecated in SWAN v3.25.0.
Use AdaptiveCarousel instead, which has improved performance and increased consistency for customers. See Deprecation for more information.
Carousel is only available in the React API for SWAN.
The preview has been updated.
Use skin="full" to indent the arrows on top of the slides and clip to the limits of the Carousel.
The preview has been updated.
Use skin="promo-bar" to wrap a "promo bar" in a Carousel.
The preview has been updated.
Use peek with an infinitely-scrolling Carousel to make previous/next slides "peek" out from both edges, to show that there are more slides.
Note: the peek feature expects that you are using a Carousel with infinite scrolling. Setting the infinite prop to false will break the Carousel if peek is also true. If you need a Carousel that is finite, but also shows a peek of adjacent slides, set slidesToShow to a non-integer value such as 1.2; see below.
The preview has been updated.
Use slidesToShow to define how many slides are visible. Different values can be set for Responsive System breakpoints, for example {{ xs: 2, md: 6 }}. Decimal values are not supported and will be rounded down.
The preview has been updated.
Use slidesToShow with a decimal value to create a peek effect on the right edge.
The preview has been updated.
gridGuttersVariant is deprecated in SWAN v3.14
As it is rarely used, it has been deprecated to improve consistency for customers and to maintain consistency with GridContainer and reduce UX debt.
Use gridGutters to place gutters (gaps) between each slide. These gutters will match the width of the gutters on the layout Grid, so your slides will appear to be on the grid.
When using the gridGutters prop, slides should have rounded corners. StandardTile already has rounded corners, but for plain images or other content, wrap your slide contents in a Card component with fullBleed and overflow="hidden".
The preview has been updated.
Use a custom padding around each slide, using Space, to achieve a spacing different from the gridGutters: be aware that it will create a left and right inner indent, and the content won't look "on the grid" anymore.
The preview has been updated.
Use arrows={false} to hide the arrows.
Note: if the arrows are hidden, provide navigation through the Progress Indicator.
The preview has been updated.
Arrows are centered vertically by default, using the total height of the Carousel.
When displaying content such as product tiles, arrows may appear visually misaligned.
arrowVerticalPosition to adjust the arrows' vertical positioning. e.g., arrowVerticalPosition="50px" vertically centers the arrows 50px from the top of the Carousel.arrowVerticalOffset to shift arrows by a specified amount. e.g., arrowVerticalOffset="-40px" places the arrows 40px higher than the default.The preview has been updated.
Use infinite={false} to provide a finite Carousel. By default, a Carousel will scroll infinitely. The arrow will be disabled at the end of a scroll.
The preview has been updated.
Use the progressIndicator to add dots that indicate the active slide and the total number of slides.
When using this option, you must provide the prop accessibleTextForDots to the Carousel.
The preview has been updated.
Use progressIndicator="dots-inset" to make the dots overlap the content.
The preview has been updated.
Use progressIndicatorAlignment="left" to make the dots left-aligned instead of centered.
The preview has been updated.
Carousels should have a text label that describes what the carousel contains. If a nearby element acts as that label, its id should be associated with the carousel using the aria-labelledby prop. Otherwise, provide an aria-label prop with a localized text value like "Recommended products".
Any carousel that auto-advances needs to have controls to let the user pause it. Until SWAN is able to add this feature, autoplay is not supported.
Carousel uses JavaScript extensively for its layout, so when adjusting Carousel props by screen size, be mindful of the limitations of our Responsive System with SSR.
Carousel is built with react-slick, which offers props such as beforeChange, afterChange, and onInit for tracking interactions.
The preview has been updated.
SWAN's Carousel is built on top of the react-slick third-party component. See the Slick documentation for full prop descriptions.
<div /> as the root element. You can utilize the native attributes supported by <div /> tag. The ref is directly assigned to the root element, allowing you to access and manipulate it as needed.| prop | type | required | default |
|---|---|---|---|
aria-roledescriptionLocalized label for assistive tech to identify this element as a "slide" ⚠️ Deprecated - This prop will be removed in favor of SWAN's i18n system. Please opt in to the i18n system for continued support. | string | false | slide |
<div /> as the root element. You can utilize the native attributes supported by <div /> tag. The ref is directly assigned to the root element, allowing you to access and manipulate it as needed.| prop | type | required | default |
|---|---|---|---|
idSet a unique id to the carousel | string | false | null |
roleARIA role for the Carousel component. | AriaRole | false | region |
aria-labelProvides an accessible label for the carousel container
Defines a string value that labels the current element.
@see aria-labelledby. | string | false | null |
aria-labelledbyReferences of the element that labels the carousel container.
Identifies the element (or elements) that labels the current element.
@see aria-describedby. | string | false | null |
aria-roledescriptionLocalized label for assistive tech to identify carousel container element as a "carousel." ⚠️ Deprecated - This prop will be removed in favor of SWAN's i18n system. Please opt in to the i18n system for continued support. | string | false | carousel |
skinThe visual style of the Carousel. | "standard" | "promo-bar" | "full" | null | false | standard |
slidesToShowThe number of slides to show at a time. | Responsive<number> | false | 1 |
progressIndicatorSpecifies the way that slide-progress is indicated to the user. | "none" | "dots" | "dots-inset" | null | false | none |
progressIndicatorAlignmentSpecifies the alignment of the progress indicator. | "center" | "left" | null | false | center |
peekWhether to show a peek of the next slide. | boolean | null | false | false |
gridGuttersWhether to place gutters between the slides that match the grid's gutters. | boolean | null | false | false |
gridGuttersVariantWhat kind of gutters to place between slides. ⚠️ Deprecated - This is deprecated without a replacement. | string | null | false | standard |
arrowVerticalPositionThe vertical position of the arrows, as a CSS "top" property. | string | null | false | null |
arrowVerticalOffsetThe vertical offset of the arrows, relative to its CSS "top" property. | string | null | false | 0px |
accessibleTextForDotsSet accessible text for carousel dots. ⚠️ Deprecated - This prop will be removed in favor of SWAN's i18n system. Please opt in to the i18n system for continued support. | string[] | null | false | null |
accessibleTextForPreviousSet accessible text for previous button. ⚠️ Deprecated - This prop will be removed in favor of SWAN's i18n system. Please opt in to the i18n system for continued support. | string | false | null |
accessibleTextForNextSet accessible text for next button. ⚠️ Deprecated - This prop will be removed in favor of SWAN's i18n system. Please opt in to the i18n system for continued support. | string | false | null |
currentSlideThe current slide of the carousel. | number | null | false | null |
accessibleTextForVisibleSlidesLocalized text to be used in the aria-live region that announces each slide change.
Should utilize placeholders {start} and {totalSlides}, e.g. "Slide {start} of {totalSlides}".
When multiple slides are visible at a time, include {end}, e.g. "Slides {start} through {end} of {totalSlides}" ⚠️ Deprecated - This prop will be removed in favor of SWAN's i18n system. Please opt in to the i18n system for continued support. | string | null | false | Slide {start} of {totalSlides}' | 'Slides {start} through {end} of {totalSlides} |
accessibleTextForSlideLocalized text to be used as the aria-label for each slide.
Should utilize placeholders {current} and {totalSlides}, e.g. "{current} of {totalSlides}". ⚠️ Deprecated - This prop will be removed in favor of SWAN's i18n system. Please opt in to the i18n system for continued support. | string | null | false | {current} of {totalSlides} |
SWAN's Internationalization System allows SWAN components to render with fully translated and accessible text out-of-the-box. The following keys are provided to allow you to override the default translation.
| Default Text | Key |
|---|---|
slide Accessible description for a single item in a Carousel component, used for aria-roledescription, i.e. a Carousel slide | carousel-slide.aria-roledescription |
Go to slide {{slideNumber}} | carousel.accessible-text-for-dot-button |
Go to next slide | carousel.accessible-text-for-next-button |
Go to previous slide | carousel.accessible-text-for-previous-button |
{{current}} of {{totalSlides}} | carousel.accessible-text-for-slide |
Slide {{start}} of {{totalSlides}} | carousel.accessible-text-for-visible-slides_one |
Slides {{start}} to {{end}} of {{totalSlides}} | carousel.accessible-text-for-visible-slides_other |
carousel Accessible description for a Carousel component, used for aria-roledescription | carousel.aria-roledescription |
How does Carousel meet your needs?