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 for the
lightning-carousel component.
You can specify up to six images, which then appear in the order that 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 shows 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.
Use lightning-carousel-image within lightning-carousel, which implements the carousel blueprint in the Salesforce Lightning Design System (SLDS). The carousel adapts to SLDS 1 or SLDS 2 styling based on the org's theme or the container app that you use.
| SLDS 1 | SLDS 2 | |
|---|---|---|
| Design | Carousel | Carousel |
| For Use In | Lightning Experience, Experience Builder Sites, Salesforce Mobile App, Lightning Out (Beta), Standalone Lightning App | Lightning Experience |
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 doesn’t load because the user is offline or another reason, the description and alternative text replace 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 appears 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.