Carousel
The Carousel component allows you to display a series of slides, such as products or images, in a horizontal or vertical scrollable UI. You can customise the carousel's appearance and functionality with several properties.
Key Properties:
- title (optional): A heading shown above the carousel, e.g.
"Training Shoes". When set, it is also used as the carousel's accessible name. - slideOrientation: Defines how the carousel slides are displayed. Use the following values:
- horizontal: For landscape images.
- vertical: For portrait images.
- square: For square images.
- none: No specific orientation.
- slideSize (optional):
"default"or"small". A small carousel is a compact, scrollable row of image tiles with the price over each image and the title underneath, e.g. for recommendations after a Product Card. Its header shows thetitle, the number of items and previous/next buttons. Small tiles use the slide's first variant and have no variant or size pickers; withenableAddToCart, a "+" button is shown on slides that have at most one size.slideOrientationis not used, and a carousel withmultiSelectEnabledalways uses the default size. - carouselType (optional): Defines the type of carousel which is used for analytics, e.g.
product-carousel. Aproduct-recommendationcarousel also shows a share button on each slide that has anexternalLink(see Sharing slides). - multiSelectEnabled (optional): When enabled, multiple slides can be selected and submitted. The submitted payload becomes an array of slide ID's.
- enableAddToCart (optional): When enabled and add to cart is available on the site (a Shopify store,
callbacks.onAddToCart, or a configuredecomPlatformandcartrequest; see Add to Cart), the carousel slides will display an "Add to cart" button. - enableMoreDetails (optional): When enabled, each slide shows a View details button that opens the same details view as the Product Card: an image gallery, option pickers, Add to cart (when
enableAddToCartis set and the carousel isn'tmultiSelectEnabled), a description, a list of attributes and a link to the product page. WithenableAddToCart, the slide itself has no Add to cart button or size picker: sizes are picked and added to the cart in the details view. Colours picked on the slide carry into the details view, and options picked there are shown on the slide. Turning it on also enables the slide'svariantGroups(see More details). Not used for small carousels (slideSize: "small"), but a small carousel withmultiSelectEnableduses the default size, so its slides show the button. - payload: An array of objects where each object represents a single slide. The following properties can be included:
-
id: The unique identifier for the slide (e.g., a product).
-
trackingId (optional): Used for analytics tracking, must be a string.
-
image: A URL to the image displayed for the slide. Not required if variants are provided.
-
title: The name/title of the slide.
-
price (optional): Displays the price on the slide (overridden by variant prices, if any). Supports markdown.
-
externalLink (optional): A URL that opens when the slide card is clicked. If no externalLink is provided, clicking the slide sends the carousel select event.
-
buttonText (optional): Used for the slide card's accessible label when no externalLink is provided.
-
disabled (optional): Whether the slide is disabled.
-
variants (optional): If variants are provided, thumbnail buttons for each variant will be displayed. Variant-specific data, such as price, externalLink, trackingId, and sizes, override the top-level values when selected.
-
sizes (optional, requires
enableAddToCart): Size options to pick before Add to cart (e.g. shoe size, strap length). WithenableMoreDetailsthey are picked in the details view instead of on the slide. Can be set on the slide or on each variant — variant sizes win when present. Each entry is{ id, label, price?, disabled?, cartParams? }; 2+ entries show a "Select size" step. Selected sizeid/priceoverride the slide and itslabelis appended to the title — same pattern asvariants. -
cartParams (optional, requires
enableAddToCart): Extra string fields added to a configured add to cart request body (they can't replace fields the config sets), e.g.{ "super_attribute[93]": "52" }. Can be set on the slide, each variant and each size; they are layered, with size params overriding variant params, which override slide params. See Add to Cart. -
images, subtitle, badge, description, attributes, variantGroupLabel, variantLabel, sizeLabel, variantGroups (optional, require
enableMoreDetails): Shown in the details view. See More details.
-
Example Carousel Configuration with Variants:
{
"type": "carousel",
"title": "Apples",
"slideOrientation": "horizontal",
"carouselType": "product-carousel",
"payload": [
{
"id": 1,
"trackingId": "apple",
"image": "https://www.some-cdn/image1.jpg",
"title": "Apple",
"externalLink": "http://google.com",
"price": "£10",
"variants": [
{
"id": 8,
"image": "https://www.some-cdn/image1.jpg", // Required
"name": "Red apple",
"price": "£1",
"externalLink": "http://google.com",
"trackingId": "111"
},
{
"id": 9,
"image": "https://www.some-cdn/image2.jpg", // Required
"name": "Green apple",
"price": "£2",
"externalLink": "http://google.com",
"trackingId": "222"
}
]
}
]
}Carousel Variant Properties:
{
id: string | number; // Required
image: string; // Required
name?: string; // Optional
price?: string; // Optional
externalLink?: string; // Optional
trackingId?: string; // Optional
sizes?: CarouselSizeOption[]; // Optional — overrides slide sizes when this variant is selected
cartParams?: Record<string, string>; // Optional — layered over the slide's cartParams
images?: string[]; // Optional — details view gallery, requires enableMoreDetails
}Example Carousel Configuration with Sizes (requires enableAddToCart):
enableAddToCart):{
"type": "carousel",
"slideOrientation": "horizontal",
"carouselType": "product-carousel",
"enableAddToCart": true,
"payload": [
{
"id": "runner-low",
"trackingId": "runner-low",
"image": "https://www.some-cdn/runner-low.jpg",
"title": "Runner Low Trainer",
"price": "£78",
"sizes": [
{ "id": "runner-low-uk5", "label": "5" },
{ "id": "runner-low-uk6", "label": "6" },
{ "id": "runner-low-uk7", "label": "7", "disabled": true },
{ "id": "runner-low-uk8", "label": "8" }
]
},
{
"id": "belgravia-30",
"trackingId": "belgravia-30",
"image": "https://www.some-cdn/belgravia-30.jpg",
"title": "Belgravia 30 Watch",
"price": "£149",
"sizes": [
{ "id": "belgravia-30-standard", "label": "Standard" },
{ "id": "belgravia-30-extended", "label": "Extended" }
]
}
]
}Example Carousel Configuration with Sizes on Variants (requires enableAddToCart):
enableAddToCart):{
"type": "carousel",
"slideOrientation": "horizontal",
"carouselType": "product-carousel",
"enableAddToCart": true,
"payload": [
{
"id": "runner-low",
"trackingId": "runner-low",
"image": "https://www.some-cdn/runner-low-black.jpg",
"title": "Runner Low Trainer",
"price": "£78",
"variants": [
{
"id": "runner-low-black",
"name": "Black",
"image": "https://www.some-cdn/runner-low-black.jpg",
"sizes": [
{ "id": "runner-low-black-uk8", "label": "8" },
{ "id": "runner-low-black-uk9", "label": "9" },
{ "id": "runner-low-black-uk10", "label": "10", "disabled": true }
]
},
{
"id": "runner-low-white",
"name": "White",
"image": "https://www.some-cdn/runner-low-white.jpg",
"sizes": [
{ "id": "runner-low-white-uk8", "label": "8" },
{ "id": "runner-low-white-uk9", "label": "9" }
]
}
]
}
]
}Carousel Size Properties:
{
id: string | number; // Required — becomes item.id in onAddToCart
label: string; // Required — shown on the chip, e.g. "M", "9", "Standard"
price?: string; // Optional — overrides the slide price when this size is selected
disabled?: boolean; // Optional — out of stock; shown, not selectable
}More details
With enableMoreDetails, the View details button on each slide opens the Product Card details view for that slide. The slide fields are read the same way as a product card's payload, so the Product Card properties apply:
- images: Images for the details view gallery. Falls back to
image. Variants and groups can have their ownimagestoo. - subtitle and badge: Shown above the title in the details view.
- description: Shown in the details view. Supports markdown.
- attributes: A list of
{ label, value }pairs shown as a table in the details view. - variantGroupLabel, variantLabel, sizeLabel: Labels for the option pickers in the details view. Default to "Option", "Colour" and "Size".
- variantGroups: An optional level above variants, e.g. shoe widths, each with its own
variants,sizes,price,discountPrice,image,images,externalLinkandcartParams. Picked in the details view when there are two or more groups; the slide then shows the chosen group's variants and price. A group without its own variants or sizes uses the slide's. The group'slabelis added to the selection and add to cart title (e.g.Clifton 11 - Wide - Black - 10) when there's more than one group, and itscartParamsare layered between the slide's and the variant's. WithoutenableMoreDetails,variantGroupsis ignored.
The details view doesn't send a carousel selection to the flow: selecting the slide card still does that.
{
"type": "carousel",
"slideOrientation": "vertical",
"carouselType": "product-carousel",
"enableAddToCart": true,
"enableMoreDetails": true,
"payload": [
{
"id": "clifton-11",
"trackingId": "clifton-11",
"title": "Clifton 11",
"image": "https://www.some-cdn/clifton-white.jpg",
"price": "$155.00",
"subtitle": "Men's | Everyday Running",
"description": "A **max-cushioned** everyday trainer.",
"attributes": [{ "label": "Drop", "value": "5mm" }],
"variantGroupLabel": "Width",
"variantLabel": "Color",
"sizeLabel": "US Size",
"variantGroups": [
{
"id": "regular",
"label": "Regular",
"variants": [
{
"id": "clifton-11-r-white",
"name": "White",
"image": "https://www.some-cdn/clifton-white.jpg",
"sizes": [
{ "id": "clifton-11-r-white-9", "label": "9" },
{ "id": "clifton-11-r-white-10", "label": "10" }
]
}
]
},
{
"id": "wide",
"label": "Wide",
"price": "$160.00",
"variants": [
{
"id": "clifton-11-w-black",
"name": "Black",
"image": "https://www.some-cdn/clifton-black.jpg",
"sizes": [
{ "id": "clifton-11-w-black-9", "label": "9" },
{ "id": "clifton-11-w-black-10", "label": "10" }
]
}
]
}
]
}
]
}Sharing slides
When carouselType is product-recommendation, each slide with an http or https externalLink shows a share button in the top right corner of its image. Tapping it opens the device's share sheet (the Web Share API) with the slide's link, the product name as the share title and a short message from lang.carouselShareText as the text (default: Thought you might like this: {productName}, where {productName} is the slide's title). When a variant is selected, its externalLink is shared and the product name becomes Title - Variant name (using the variant's title if it has one).
The button only appears in browsers that support Web Share, which requires the page to be served over HTTPS. Where it is unsupported the slide looks exactly as before.
Sharing isn't tracked: it doesn't send a chat event, call onCarouselSelection, update the cart or send a selection to the flow.
Callbacks for Carousel Events:
onCarouselDisplay: Triggered when the carousel is displayed. The carouselType (if provided) is passed to the callback.
<script>
window.DG_CHAT_WIDGET_CONFIG = {
callbacks: {
onCarouselDisplay: (carouselType) => {
console.log(carouselType);
}
}
}
</script>onCarouselSelection: Triggered when a slide is selected. This callback receives the trackingId, slideData, carouselType, and carouselPayload as parameters.
<script>
window.DG_CHAT_WIDGET_CONFIG = {
callbacks: {
onCarouselSelection: (trackingId, slideData, carouselType, carouselPayload) => {
console.log(trackingId, slideData, carouselType, carouselPayload);
}
}
}
</script>Updated 7 days ago
