The Ignite UI for Web Components Carousel is a responsive, lightweight component that provides the most flexible way to create slideshow-like web experience for users who navigate back and forth through a collection of images with text slides, links, and other html elements.
The Web Components Carousel component allows you to use animations, slide transitions, and customization so you can easily tweak the interface and build Web Components custom carousel.
Web Components Carousel Example
The Web Components Carousel demo you see below shows slides containing only images.
<!DOCTYPE html><html><head><title>Carousel Overview</title><metacharset="UTF-8" /><linkrel="shortcut icon"href="https://static.infragistics.com/xplatform/images/browsers/wc.png" ><linkrel="stylesheet"href="https://fonts.googleapis.com/icon?family=Material+Icons" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Kanit&display=swap" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Titillium Web" /><linkrel="stylesheet"href="https://static.infragistics.com/xplatform/css/samples/shared.v8.css"type="text/css" /></head><body><divid="root"><divclass="carousel-container"><igc-carousel><igc-carousel-slide><divclass="image-container"><imgsrc="https://www.infragistics.com/angular-demos-lob/assets/images/carousel/ignite-ui-angular-indigo-design.png"/></div></igc-carousel-slide><igc-carousel-slide><divclass="image-container"><imgsrc="https://www.infragistics.com/angular-demos-lob/assets/images/carousel/slider-image-chart.png"/></div></igc-carousel-slide><igc-carousel-slide><divclass="image-container"><imgsrc="https://www.infragistics.com/angular-demos-lob/assets/images/carousel/ignite-ui-angular-charts.png"/></div></igc-carousel-slide></igc-carousel></div></div><!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %><scriptsrc="src/index.ts"></script><% } %>
</body></html>html
For a complete introduction to the Ignite UI for Web Components, read the Getting Started topic.
Now that you have the Ignite UI for Web Components Carousel imported, you can start with a basic configuration of the IgcCarouselComponent and its slides.
Use the IgcCarouselComponent selector to wrap your slides. The slides may feature any valid html content inside, including other components.
If no active slide is set, the first one will be set by default. If there are multiple active slides on initial rendering or subsequent updates, only the last one will be taken into account.
Examples
Carousel Configuration
By default, the IgcCarouselComponent has its disableLoop property set to false (looping occurs when the first slide comes after the last by navigating using the Next action, or when the last slide comes after the first by using the Previous action). The looping behavior can be disabled by setting the value of the disableLoop property to true.
To keep track of each slide index, the carousel has indicators that are positioned at the end of the carousel by default. In order to change this behavior, use the indicatorsOrientation property and assign it to start.
By default, the IgcCarouselComponent displays its navigation buttons and indicators. Use the hideIndicators property to hide the indicators and the hideNavigation property to hide the navigation buttons.
The Ignite UI for Web Components Carousel component allows users to use different elements for the active and inactive state of a single indicator. It is mandatory to provide two elements for each slot (empty and active) when declaring an indicator, even if they are the same.
Custom navigation buttons
To achieve this, use the previous-button and next-button slots:
<!DOCTYPE html><html><head><title>Carousel With Components</title><metacharset="UTF-8" /><linkrel="shortcut icon"href="https://static.infragistics.com/xplatform/images/browsers/wc.png" ><linkrel="stylesheet"href="https://fonts.googleapis.com/icon?family=Material+Icons" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Kanit&display=swap" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Titillium Web" /><linkrel="stylesheet"href="https://static.infragistics.com/xplatform/css/samples/shared.v8.css"type="text/css" /></head><body><divid="root"><divclass="carousel-container"><igc-carousel><igc-carousel-slide><div><imgsrc="https://www.infragistics.com/angular-demos-lob/assets/images/svg/carousel/SignUp.svg"><form><igc-inputtype="text"placeholder="Username"><igc-iconslot="prefix"name="person"></igc-icon></igc-input><igc-inputtype="password"placeholder="Password"><igc-iconslot="prefix"name="password"></igc-icon></igc-input><igc-buttontype="reset">Sign In</igc-button></form></div></igc-carousel-slide><igc-carousel-slide><div><imgsrc="https://www.infragistics.com/angular-demos-lob/assets/images/svg/carousel/Route.svg"><form><igc-inputtype="text"placeholder="Search"><igc-iconslot="prefix"name="search"></igc-icon></igc-input><igc-buttontype="reset">Search</igc-button></form></div></igc-carousel-slide></igc-carousel></div></div><!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %><scriptsrc="src/index.ts"></script><% } %>
</body></html>html
<!DOCTYPE html><html><head><title>Carousel Animations</title><metacharset="UTF-8" /><linkrel="shortcut icon"href="https://static.infragistics.com/xplatform/images/browsers/wc.png" ><linkrel="stylesheet"href="https://fonts.googleapis.com/icon?family=Material+Icons" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Kanit&display=swap" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Titillium Web" /><linkrel="stylesheet"href="https://static.infragistics.com/xplatform/css/samples/shared.v8.css"type="text/css" /></head><body><divid="root"><divclass="carousel-wrapper"><divclass="action-wrapper"><divclass="action"><span>Animation type</span><igc-selectid="select"><igc-select-itemvalue="slide"selected>Slide</igc-select-item><igc-select-itemvalue="fade">Fade</igc-select-item><igc-select-itemvalue="none">None</igc-select-item></igc-select></div><divclass="action"><igc-switchlabel-position="before">Vertical alignment</igc-switch></div></div><igc-carouselhide-indicators><igc-carousel-slide><divclass="slide-wrapper"><igc-card><igc-card-header><h3slot="title">Ignite UI for Angular</h3></igc-card-header><igc-card-content><p>30+ Material-based Angular components to code speedy web apps faster.</p></igc-card-content><igc-card-media><imgsrc="https://www.infragistics.com/angular-demos-lob/assets/images/carousel/slide1-angular.png"></igc-card-media><igc-card-actions><igc-buttonslot="start"href="https://www.infragistics.com/products/ignite-ui-angular"target="_blank"rel="noopener">
Visit Page
</igc-button></igc-card-actions></igc-card></div></igc-carousel-slide><igc-carousel-slide><divclass="slide-wrapper"><igc-card><igc-card-header><h3slot="title">Ignite UI for Javascript</h3></igc-card-header><igc-card-content><p>A complete JavaScript UI library empowering you to build data-rich responsive web apps.</p></igc-card-content><igc-card-media><imgsrc="https://www.infragistics.com/angular-demos-lob/assets/images/carousel/slide2-ignite.png"></igc-card-media><igc-card-actions><igc-buttonslot="start"href="https://www.infragistics.com/products/ignite-ui"target="_blank"rel="noopener">
Visit Page
</igc-button></igc-card-actions></igc-card></div></igc-carousel-slide><igc-carousel-slide><divclass="slide-wrapper"><igc-card><igc-card-header><h3slot="title">Ultimate UI for ASP.NET</h3></igc-card-header><igc-card-content><p>Build full-featured business apps with the most versatile set of ASP.NET AJAX UI controls.</p></igc-card-content><igc-card-media><imgsrc="https://www.infragistics.com/angular-demos-lob/assets/images/carousel/slide3-aspnet.png"></igc-card-media><igc-card-actions><igc-buttonslot="start"href="https://www.infragistics.com/products/aspnet"target="_blank"rel="noopener">
Visit Page
</igc-button></igc-card-actions></igc-card></div></igc-carousel-slide></igc-carousel></div></div><!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %><scriptsrc="src/index.ts"></script><% } %>
</body></html>html
Transition and navigation are the most important carousel features.
The navigation in the carousel can be handled by the user through navigation buttons, indicators, keyboard navigation and touch interaction on mobile devices.
Touch gestures
By default, the carousel can be used on any touch-enabled device.
The carousel animations are fully supported on touch devices, which makes the carousel consistent with any platform and great when used in progressive web applications (PWA).
Keyboard navigation
Navigation buttons
Space/Enter key - navigates to the next/previous slide.
Indicators
Arrow Left key - navigates to the previous (next in Right-to-Left mode) slide.
Arrow Right key - navigates to the next (previous in Right-to-Left mode) slide.
Home key - navigates to the first (last in Right-to-Left mode) slide.
End key - navigates to the last (first in Right-to-Left mode) slide.
Automatic transitioning
The IgcCarouselComponent can be easily configured to change the slides automatically, without any user interaction. This way you can create your own slideshow by only setting a transition interval to the interval property, which determines the amount of time in milliseconds between slides transition.
Hovering the mouse over any carousel content or moving keyboard focus to any of the carousel content pauses automatic transitioning. Automatic transitioning resumes when the mouse moves away from the carousel or when keyboard focus moves out of the carousel content. This can be prevented by setting disablePauseOnInteraction property to true.
<!DOCTYPE html><html><head><title>Carousel Thumbnail</title><metacharset="UTF-8" /><linkrel="shortcut icon"href="https://static.infragistics.com/xplatform/images/browsers/wc.png" ><linkrel="stylesheet"href="https://fonts.googleapis.com/icon?family=Material+Icons" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Kanit&display=swap" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Titillium Web" /><linkrel="stylesheet"href="https://static.infragistics.com/xplatform/css/samples/shared.v8.css"type="text/css" /></head><body><divid="root"><divclass="container sample"><igc-carouseldisable-pause-on-interactionhide-navigationinterval="2000"verticalanimation-type="fade"
><igc-carousel-indicator><imgclass="blurred"src="https://www.infragistics.com/angular-demos-lob/assets/images/carousel/WonderfulCoastThumb.png"alt="Wonderful Coast Thumb"width="50"height="60"
/><imgslot="active"src="https://www.infragistics.com/angular-demos-lob/assets/images/carousel/WonderfulCoastThumb.png"alt="Wonderful Coast Thumb Active"width="50"height="60"
/></igc-carousel-indicator><igc-carousel-indicator><imgclass="blurred"src="https://www.infragistics.com/angular-demos-lob/assets/images/carousel/CulturalDipThumb.png"alt="Cultural Dip Thumb"width="50"height="60"
/><imgslot="active"src="https://www.infragistics.com/angular-demos-lob/assets/images/carousel/CulturalDipThumb.png"alt="Cultural Dip Thumb Active"width="50"height="60"
/></igc-carousel-indicator><igc-carousel-indicator><imgclass="blurred"src="https://www.infragistics.com/angular-demos-lob/assets/images/carousel/GoldenBeachesThumb.png"alt="Golden Beaches Thumb"width="50"height="60"
/><imgslot="active"src="https://www.infragistics.com/angular-demos-lob/assets/images/carousel/GoldenBeachesThumb.png"alt="Golden Beaches Thumb Active"width="50"height="60"
/></igc-carousel-indicator><igc-carousel-indicator><imgclass="blurred"src="https://www.infragistics.com/angular-demos-lob/assets/images/carousel/IslandOfHistoryThumb.png"alt="Island Of History Thumb"width="50"height="60"
/><imgslot="active"src="https://www.infragistics.com/angular-demos-lob/assets/images/carousel/IslandOfHistoryThumb.png"alt="Island Of History Thumb Active"width="50"height="60"
/></igc-carousel-indicator><igc-carousel-indicator><imgclass="blurred"src="https://www.infragistics.com/angular-demos-lob/assets/images/carousel/AmazingBridgeThumb.png"alt="Amazing Bridge Thumb"width="50"height="60"
/><imgslot="active"src="https://www.infragistics.com/angular-demos-lob/assets/images/carousel/AmazingBridgeThumb.png"alt="Amazing Bridge Thumb Active"width="50"height="60"
/></igc-carousel-indicator><igc-carousel-slide><imgsrc="https://www.infragistics.com/angular-demos-lob/assets/images/carousel/WonderfulCoast.png"alt="Wonderful Coast"
/></igc-carousel-slide><igc-carousel-slide><imgsrc="https://www.infragistics.com/angular-demos-lob/assets/images/carousel/CulturalDip.png"alt="Cultural Dip"
/></igc-carousel-slide><igc-carousel-slide><imgsrc="https://www.infragistics.com/angular-demos-lob/assets/images/carousel/GoldenBeaches.png"alt="Golden Beaches"
/></igc-carousel-slide><igc-carousel-slide><imgsrc="https://www.infragistics.com/angular-demos-lob/assets/images/carousel/IslandOfHistory.png"alt="Island Of History"
/></igc-carousel-slide><igc-carousel-slide><imgsrc="https://www.infragistics.com/angular-demos-lob/assets/images/carousel/AmazingBridge.png"alt="Amazing Bridge"
/></igc-carousel-slide></igc-carousel></div></div><!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %><scriptsrc="src/index.ts"></script><% } %>
</body></html>html
The Carousel base element role is region - section containing content that is relevant to specific purpose and users will likely want to be able to navigate easily.
Carousel indicators are with role tab - grouping label providing a mechanism for selecting the tab content that is to be rendered to the user
The element that serves as the container for the set of tabs (carousel indicators) is with role tablist.
aria-live - used to set the priority with which screen reader should treat updates to live regions - the possible settings are: off and polite. The default setting is polite and is set to the element that serves as the container for the set of slides. When the interval option is set and the carousel is in playing state, the aria-live attribute would be set to off.