Carousel Image
lightning-carousel-image
Specifies an image that's used in lightning-carousel, including description and title
For Use In
Lightning Experience, Experience Builder Sites, Salesforce Mobile App, Lightning Out (Beta), Standalone Lightning App
Use the lightning-carousel-image component to specify images to display in the
lightning-carousel component.
You can specify up to six images. The images are displayed in the order you
list them in the lightning-carousel component.
For each image, use the src attribute to specify the path to the image.
Optionally use header and description attributes to provide a header
and descriptive text that the carousel displays below the image.
You can also hyperlink the images with the href attribute.
Use the alternative-text attribute to supply assistive text for each image.
This component implements styling from carousel in the Lightning Design System.
This example creates a basic carousel with three images.
To use images in your org, upload them as static resources in the Static Resources
page in Setup. To reference a resource in lightning-carousel-image, use {property}
syntax in your src attribute.
If the image path is invalid or the image does not load because the user is offline or another reason, the description and alternative text are shown in place of the image.
This example uses static resources uploaded as a single image, and images uploaded in a zip file.
The company logo was uploaded as a single image to a static resource named company_logo and imported as companyLogo. The Product1 and Product2 images were uploaded in a zip file to a static resource named company_products and imported as companyProducts.
lightning-carousel-image includes accessibility features provided by lightning-carousel. A carousel image is displayed with header text and a description. Use the alternative-text attribute to specify assistive text for each image.
lightning-carousel-image observes these roles, states, and properties.
- The indicator button (tab's anchor) of a selected image has
aria-selected="true", and all other tabs havearia-selected="false". - The tab's anchor of a selected image has
tabindex="0", and all other tabs havetabindex="-1". - Each image container (tab panel) contains an element with
role="tabpanel". - Each tab panel has an
aria-labelledbyattribute whose value is the ID of its associated indicator button. - Each tab panel has an
aria-hiddenattribute whose value is toggled based on whether the panel is visible.