<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-5HGSQD2L" height="0" width="0" style="display:none;visibility:hidden" title="GTM"></iframe>

Carousel

A carousel allows multiple pieces of content to be browsed in a cyclical view.
styleKeys: carousel
Info:

Carousel is only available in the React API for SWAN.

Use Carousel...

  • In non-hero spots on the page, as a secondary element to showcase products or related content.
  • To display a series of content when space is limited.
  • To showcase a limited number of slides (2-4) to ensure user engagement and recall.

Don't use Carousel...

  • In a hero spot (a wide banner at the top of the page), as it leads to significantly lower engagement beyond the first slide.
  • To display SEO-relevant information, as search engines cannot index content that requires user interaction to view.

Default

The preview has been updated.

Skin

Full

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.

Promo-bar

Use skin="promo-bar" to wrap a "promo bar" in a Carousel.

The preview has been updated.

Peek

Use peek with an infinitely-scrolling Carousel to make previous/next slides "peek" out from both edges, to show that there are more slides.

Info:

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.

Slides to show

Use slidesToShow with multiple values for different screen sizes, such as {{xs: 2, lg: 6}}. This feature works with server-side rendering and will not have a flicker when JavaScript kicks in (which was not the case in SWAN 2 or earlier).

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.

Grid Gutters

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.

Arrows

Visibility

Use arrows={false} to hide the arrows.

Note: if the arrows are hidden, provide navigation through the Progress Indicator.

The preview has been updated.

Positioning

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.

  • Use arrowVerticalPosition to adjust the arrows' vertical positioning. e.g., arrowVerticalPosition="50px" vertically centers the arrows 50px from the top of the Carousel.
  • Use 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.

Finite

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.

Progress Indicator

Dots

Use the progressIndicator to add dots that indicate the active slide and the total number of slides.

Info:

When using this option, you must provide the prop accessibleTextForDots to the Carousel.

The preview has been updated.

Dots inset

Use progressIndicator="dots-inset" to make the dots overlap the content.

The preview has been updated.

Alignment

Use progressIndicatorAlignment="left" to make the dots left-aligned instead of centered.

The preview has been updated.

Accessibility

Autoplay

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.

Implementation

Server-side rendering

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.

Placement

  • Use Carousels only when space constraints prevent displaying all items at once.
  • Avoid Carousels in hero spots, due to lower engagement beyond the first slide.

Content

  • Avoid placing SEO-relevant information in a Carousel, as search engines cannot index content requiring user interaction.
  • Limit slides to between two and four, as users are unlikely to recall or swipe past five slides.

Visual design

  • Keep controls inside the Carousel and ensure they are easily recognizable.

Props

SWAN's Carousel is built on top of the react-slick third-party component. See the Slick documentation for full prop descriptions.

CarouselSlide
This component is implemented using the <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.
See core props for additional props that can be applied to this component.
Carousel
This component is implemented using the <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.
See core props for additional props that can be applied to this component.
proptyperequireddescriptiondefault
slidesToShowResponsive<number>false
The number of slides to show at a time.
1
roleAriaRolefalse
ARIA role for the Carousel component.
region
skin"standard" | "full" | "promo-bar" | nullfalse
The visual style of the Carousel. One of: "standard", "full", "promo-bar".
standard
progressIndicator"none" | "dots" | "dots-inset" | nullfalse
Specifies the way that slide-progress is indicated to the user. One of: "none", "dots", "dots-inset".
none
progressIndicatorAlignment"center" | "left" | nullfalse
Specifies the alignment of the progress indicator. One of: "left", "center".
center
peekboolean | nullfalse
Whether to show a peek of the next slide.
false
gridGuttersboolean | nullfalse
Whether to place gutters between the slides that match the grid's gutters.
false
gridGuttersVariantstring | nullfalse
What kind of gutters to place between slides.
standard
arrowVerticalPositionstring | nullfalse
The vertical position of the arrows, as a CSS "top" property.
null
arrowVerticalOffsetstring | nullfalse
The vertical offset of the arrows, relative to its CSS "top" property.
0px
accessibleTextForPreviousstringtrue
Set accessible text for previous` button.
null
accessibleTextForNextstringtrue
Set accessible text for next button.
null
currentSlidenumber | nullfalse
The current slide of the carousel.
null
accessibleTextForDotsstring[]false
Localized Accessible text for carousel dots.
null
idstringfalse
Set a unique id to the carousel
null

Related

Was this page useful?

Thanks for your feedback!

Feel free to include your name if you wish to have a follow up conversation.


Published: Jan 7, 2022Last updated: Sep 3, 2024